Re:Blog post id enumeration can lead to unwanted information...
by JoshTriplett on Monday February 29, 2016 @03:32AM
(#11194274)
> Easiest way is simply XOR the database auto-increment ID with a fixed number, then truncate to (AND to) however many bits seem reasonable for your site.
XOR has a trivial known-plaintext attack, and you don't even need to determine the entire key to get something useful. If you can create a few posts in order and obtain a series of sequential items, you can obtain the low-order bits of the number XORed in, at which point you can easily browse around for adjacent items from any post.
Not super secure, but good enough for this purpose.
Unless you have a long ID people can always simply try every ID, no matter what format you use. So fancy encryption on the ID isn't all that useful.
If security is important then generate a random 64bit number and store that, rather than let the database auto-generate a number.