** EDIT **
I found some problems with my code. =) Did some research on PHP’s crypt() and found out that the salt doesn’t quite work they way I had expected it to. Going to post a revision soon.
This is my version of a PHP TripCode (that I will be using for No-Mess-Enger). The way it works is, the user chooses a name, and a key. That information along with the randomly generated URI generate an integer that will eventually be used to select a random animal or something like that. This will allow users to remain anonymous while upholding the integrity of the users authenticity, in case another user tries to choose the same name.
function utilMakeTripcode($alias,$key,$uri) { # generate tripcode $s = crypt($alias,"$key#$uri"); $r = ''; for($i=0;$i<strlen($s);$i++) { $r.= hexdec(substr($s,$i,1)); } return bindec($r); }
Example:
- User enters the Alias: Jon
- User enters the Key: SecretWord
- The TripCode Int generated is 101
At this point I can use something like this to select the users animal:
$usersAnimal = $allAnimals[$maxAnimals-$maxAnimals%$tripCodeInt];
In this example $allAnimals is an array holding every Animal name. $maxAnimals is the array size, and $tripCodeInt is the integer generated from the utilMakeTripCode() function.
So now when the user talks in Chat he might be called:
Jon the Koala
** Note **
I’ve only TESTED the function. Can’t verify that the second snippet works exactly that way. It’s more pseudo code.. so don’t hate me if it’s not quite right. ^.^
