This is related to a programming problem I have, but posted here because I think I'll get a better answer.
I've got database records that have ID's 1,2,3,.... Assume I'll never have more than a couple million records. Currently you can view that data by http://mysite/000000001, http://mysite/000000002, etc. Manager would rather those numbers look more random so people don't think "oh I'm the 352nd person to sign up". Are there any quick ways to generate a 1-1 reversible mapping that looks basically random?
- Deterministically scrambling the digits and adding some constant is easily reversible but not quite random-looking enough.
- I know I can multiply by a prime factor of N (say I choose N to be a billion, I can multiply by 384720347) and then mod by N, which will give a 1-1 mapping. That's probably the lower bound on "random-looking", but doesn't seem easily reversible. (Correct me if I'm wrong).
- Of course I don't want to create a million-item lookup table.
- "N" isn't restricted to anything in particular, other than being somewhere between (say) a billion and a trillion. If an algorithm only works assuming N is prime, or N is a power of 2, or N is 932483920 then that's acceptable.