Here's a neat problem. I love it when I get problems like this one, they make my job worthwhile.
I have a system with users, each of which have a unique name (a string).
For each user in our system, we need a "passcode" - it's like a numeric password.
The pass code must be as unique as their name. like, a one-way cipher that will always turn "Bob" into "3241" and "Mary" into "5588".
What is the fastest, MOST ELEGANT way to do this? In PHP, of course.
Just for aesthetic reasons, it should be 4 or 5 digits. Any less and they won't think it's secure enough, any more then it'll be hard to remember.
Do I convert the text to decimal? extract the digits from an MD5? Employ a substitution cipher on each character using array_walk()? seed a rand() using the sum of the string's ord() values?
I'm looking for something elegant here