Here is simply another way of using the first three octets of the users ip address to create a hexadecimal string that can be used as html color argument.
#!/usr/bin/perl -w use strict; my @octets = split(/\./, $ENV{'REMOTE_ADDR'}); pop(@octets); my @hexval; push(@hexval, dec2hex($_)) for (@octets); my $hex = join("", @hexval); print "Content-type: text/html; charset=ISO-8859-1\n\n"; print "The hex value is: <font color=$hex>$hex</font>\n"; sub dec2hex { my $decnum = shift; my ($hexnum, $modulus, @hexval); $hexnum = int($decnum / 16); $hexnum = chr($hexnum + 55) if ($hexnum > 9); push(@hexval, $hexnum); $modulus = $decnum % 16; $modulus = chr($modulus + 55) if ($modulus > 9); push(@hexval, $modulus); return join("", @hexval); }

Not sure how you plan on making it irreversible. If you use the method of converting the IP into a hex number it will always be able to be reversed if anyone figures out how you vreate the hex. However all that will be able to be recovered is the first three octets. Also with this method you have the possibility of having 253 users (255 minus 1 for broadcast and one for gateway) with the same color. Be it a very very small chance that every user from that IP range will visit your site at once.


In reply to Re: Creative presentation algorithm: IP to a color by Elijah
in thread Creative presentation algorithm: IP to a color by Your Mother

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.