0

I have about 70,000 items in a database. I want to serve these items to the public with an id which is currently in sequential order (1, 2, 3, 4 ....).

I don't want someone with a bot to just look up requests in the obvious order. I want to scramble the numbers into something like (93472394, 30842085, 20394230 ...). I want to have some space in between but doesn't have to be always. For example, if I serve item #93472394, there may or may not be a 93472395.

Right now I only have one type of item: for example, birds. Next I would like to add reptiles, then mammals, etc. I expect the items to increase as well.

I realize I may be asking a lot here, if so, is there more information about this type of permutation? In other words, hiding a sequential numbering system to something more complicated like credit cards and account numbers. Thanks!

Edit: I want my front-end client program to do some checking before sending a request if possible. So for example, if every other digit adds up to something. Or some similar check system as described in this video.

Cit5
  • 115
  • I think so... I've read about SHA-1 and cryptography, when I was trying to understand SSL certification. But I think I need something more simple. I want to embed types within the item id as well. For example, something like: birds from North America (xxx43xxx), Europe (xxx78xxx), like in credit cards or barcodes. Not just random integers necessarily. I'm not quite sure how to implement the random shuffle either but I definitely do need to do some more reading on this topic. – Cit5 Dec 03 '17 at 22:00

1 Answers1

0

Sometimes-Recurse Shuffle by Ben Morris and Phillip Rogaway solves this problem in a secure manner without having to store the permutation in memory.

That being said, just using a large unpredictable random number as the id and saving that id in the database is vastly easier to implement.

orlp
  • 10,508
  • Aren't link-only answers not advised? – Weather Vane Dec 03 '17 at 19:04
  • @WeatherVane The link is just there for convenience, my answer is actually a reference. Considering my reference is nontrivial (read: cannot easily be summarized) and solves exactly the OPs problem and nothing else I don't see a better way to answer the question. – orlp Dec 03 '17 at 19:06