Hacker News new | ask | show | jobs
by CipherThrowaway 1878 days ago
What you want is a cipher from 1..N to 1..N. This problem is often approached as an encryption problem known as Format Preserving Encryption. The Sometimes Recurse Shuffle linked elsewhere in this thread is one solution but the most foundational and accessible paper on this is Black and Rogaway's "Ciphers with Arbitrary Domains" The Generalized Feistel Network (Method 3) is fast and easy to implement.

https://web.cs.ucdavis.edu/~rogaway/papers/subset.pdf