Hi all --
I'm looking for a function, F(i), that takes an integer argument, i, in the range 1 .. 10^8
and returns a short string, say 8 characters long, using the 26 + 26 + 8 = 60
character set ‘A’..’Z’, ‘a’.. ‘z’, ‘2’ .. ‘9’. (I want to omit ‘0’ and ‘1’ to avoid ‘O’ and ‘l’ confusion).
F(i) must be invertible – that is, each unique i maps to a unique F(i), and each unique F(i)
maps to a unique i. And I don't want psuedo-random function (eg just build up a random string then cache it to a file or a DB to ensure that string is not reused); I'm lookling for something deterministic.
The number of valid strings (10^8) is much less than the
number of possible strings (60^8), so the chance of guessing a correct string is extremely low.
Do you have suggestions for doing this in perl? Do I want a MD5 hash or something?
If there is a canned algorithm that is pretty close to this, I can change my requirements somewhat.
I would prefer to keep the strings short to keep 'em human friendly.
Thanks, wise monks, for any tips and pointers --
rkg
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.