# Sequential numbers to unique-looking numbers

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?

-
I don't understand why this is even an issue. If your client is worried people see that they are only the 15th customer, count down from 999999999. – Raphael Feb 4 '14 at 18:09

Not sure what you mean by "totally obvious". Technically, every permutation of $\{1,...,10^8\}$ would work here. You can randomly generate such a permutation, store it in an array, and use this array as an index.
If you want a specific example, which may look at first glance non-sequential, take some big number $p$ such that $gcd(p,10^8)=1$ (e.g. $p= 19683$), then the id of user $i$ will be $i*p (\text{ mod } 10^8)$. This is guaranteed to be unique for each user (up to $10^8$ users).
Programming this, is this the math I would use? number = id * P % pow(10, 8), where P is a number like 19683`. – M Miller Feb 4 '14 at 18:27