I am developing a webapp that does not reveal record count, because it hides the primary key. I am looking for a better way to do this.
My favorite idea is to encrypt the ID itself with a block cipher, because that would require not additional tracking tables, and if the block size is equal to the key size, it should work fine.
However, I don't want a 128 bit block size, because it would take awhile to type example.com/records/MTZjaHJzRm9yMTI4Yml0cw
(Base 64 representation)
The ideal block size would be fully adjustable. I want to be able to make an 8 digit ID input that results in an 8 digit output, that is collision free by using a permanently stored random key. The input would be the real primary key, and the output would be the identifier shown to the public. I may decide to change the digit length, or to switch to Base64 identifiers, and I would like for the algorithm to be flexible enough to accomodate this?
Can you recommend an encryption routine for such short data and outputs? I don't care whether the key is short or not, only the data and output has to be.
rnd(90000000)+10000000
to have random values of 8 characters in length and then either checking for their existence and repeating generation if needed, or having a unique index on that field, trying to append data and if it fails on index value not being unique - recalculating another value. You could create (or Google for) a stored procedure in most RDBMS to do this for you.