2 ms·
A while ago, i looked into how to do something like this, and ended up asking people on sci.crypt for help. That led me to the "hasty pudding trick" - see the s
by twic 8y ago
A while ago, i looked into how to do something like this, and ended up asking people on sci.crypt for help. That led me to the "hasty pudding trick" - see the section on 'Encrypting Numbers and Dates':
http://richard.schroeppel.name:8015/hpc/hpc-spec http://richard.schroeppel.name:8015/hpc/hpc-spec
And ultimately to this this solution (which is a terrible writeup of it, sorry):
https://stackoverflow.com/a/966822/116639 https://stackoverflow.com/a/966822/116639
Basically, the hasty pudding trick lets you whittle a block cipher down so that it works on some subset of its natural domain. And you can make a block cipher for an arbitarily small block size using a Feistel network with truncated SHA-3 or whatever as the round function. So, if you want to work with IDs in the range 0 to 999999, you make a 20-bit block cipher, then use the hasty pudding trick to run it over 0-999999 instead of 0-1048575.
There's probably a better way to do this that doesn't involve building your own cipher, but i didn't work it out at the time.