I need to create a unique id for our users. I don’t want to use an auto_incrementing id, because I don’t want users to be able to guess how many users we have, or what the growth rate is.
A UUID is not really an option either, because users will have to re-type the id on a smartphone.
So I’m hoping I can reduce ‘brute-forcing’ the database as much as possible to find unused ids. What would be a smart way to go about this?
Thank you!
Create a list of random uniqe numbers (you could use PHP’s
range()andshuffle()functions), and have it stored in database or even in a txt file. Make sure the list is long enough so that it lasts for some time.Then whenever you need a new ID, just pop the first value from the list.