|
|
| No such thing as a small change | |
| PerlMonks |
Re^3: Converting a number back to it's original string (that was hashed to generate that number)by Anonymous Monk |
| on Jan 23, 2013 at 20:06 UTC ( #1015013=note: print w/ replies, xml ) | Need Help?? |
|
HOW to map both ways, in a one to one relation, (5-digit-integer <=> string) without losing any information?
Just store the filename alongside the pin into the table and it'll work pretty well. The only other way of mapping string to pin -- apart from the lookup table I've just typed out -- is enumerating over the possible filenames and hashing each in turn, comparing the result to the pin. There's no way around it with the constraints you stubbornly add. Oh, by the way, with 100 files and 10k available (random-ish) identification numbers, you might hit the birthday paradox. About 60% probable, I think. You don't want a hashing function -- you want an integer sequence. Databases provide those.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||