Reputation: 65328
Here is the id
DIAK6c
and another
65d0a2
The first id came from wahoha.com and the second came from webanswers.com. How can I produce an ID like this in my database. I have mysql with asp.net c#
Upvotes: 2
Views: 96
Reputation: 10645
That is most probably an integer number encoded to that form using a reversible algorithm, one simple way to achieve that is to convert your numeric id from base 10 to base 36:
CONV( 5234525977, 10, 36 )
result would be '2EKI23D' which you can easily convert back to integer form:
CONV( '2EKI23D', 36, 10 )
result: 5234525977
Upvotes: 1
Reputation: 62564
Try out: (10 random digits like 6422ab8810
)
SELECT LEFT(MD5(RAND()), 10)
To have sucn an Id you have to use string data type what is really not the best option from performance perspectives (index rebuild speed degrades). So rethink 10 times before using such an Id as Primary Key.
This could be some kind of extra Id in addition to main RowId which is INT PRIMARY KEY
.
Upvotes: 1
Reputation: 700910
There are basically two ways, you can either keep integer identifiers in the database and convert to character combinations when you expose them, or create character combinations (by random, hashing, permutations, et.c.) to use as keys in the database.
The second example looks like hexadecimal representation, that can easilty be created from an integer key:
int id = 6672546;
string idString = Convert.ToString(id, 16);
Upvotes: 1