in reply to Creative presentation algorithm: IP to a color
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creative presentation algorithm: IP to a color
by eXile (Priest) on Aug 29, 2005 at 05:54 UTC |