I need to issue a series {1, 2, 3, 4 …} of tickets that are (at least seemingly) random numbers {10,934, 3,453,867, 122, 4,386,564 …}. When presented back, I must be able to compute their original index (e.g. 122 → 3.)
In other words, I need a seemingly random permutation p
on the interval [1 … N] that has an inverse permutation p-1
. N is about 107.
The reasons for that are:
- It is a cipher: When receiving a ticket, it should not be easy to guess the tickets that where issued before.
- The tickets should be short alphanumeric strings that can be noted down.
- I want to avoid recording every ticket issued.