Can anyone tell me how Twitter generates the unique keys it includes in its profile URLs for members’ status pages?
e.g. https://twitter.com/UglyPrick/status/235767315856240640
The numeric part of the ID is unique and appears to be hashed in some way as simply changing the number doesn’t give you another user’s page.
What technique are they likely to use to end up with a neat numeric value like that?
I’d like to use something similar in a project of mine to pass database IDs in query strings.
Thanks.
Probably only someone from the Twitter team can answer with authority, but it could be any cryptographically sound hash function that hashes to “enough” bits to avoid any real likelihood of hash collision (see the Birthday Problem).
The particular number you show, in hex, is
0345 9D1F E742 3000
which looks like a 64 bit hash function is behind it. Google’s City Hash is a fairly strong, quite fast 64-bit hash through there are many other possibilities.