I'm not sure how to word this because I'm not familiar with this, but I'm sure a process like this is rather common.
Basically, I've got members signing up for our website, and each one is assigned a normal sequential ID (a MySQL auto_increment ID), i.e. 1
, 2
, 3
, ....
The client wants these users to have a "member number" -- something around 8 digits long. It doesn't matter if the algorithm is predictable, I just want to generate an 8-digit number that I know won't repeat and isn't totally obvious that it's sequential, e.g. I don't want to use 10000001
, 10000002
, 10000003
....
Is there a simple algorithm for generating "member numbers" in a case like this? Like I said, I don't care if it's reverse-engineerable, just as long as I know it will always be unique.
For instance, I considered just taking a hash and truncating it, e.g. md5(1)
, md5(2)
, md5(3)` in base 10 and taking the first 8 characters -- but there's always a chance of conflict, where two IDs produce a similar hash.
Any thoughts?
999999999
. $\endgroup$