DEV Community

Discussion on: Creating User-Facing, Short Unique IDs: What are the options?

realtebo profile image
Mirko Tebaldi

I am facing the need to reinvent the wheel because I also need some kind of short uuid, like amazon ASIN, generated using internal company id , user id, product id, and a second-based time stamp. But I'd like to find an algorithm to make them looks incrementals. for example, Amazon's ASIN are progressive, every new created one is comparable/sortable as greater of previous one created, but they are not a simple counter. I think I will use second-based unix-time as first part, then appending some internals id MODding each one by 4096 to keep it shorty and then rebasing obtained nubmer into base 36 (to use 26 uppercase letters plus numerbers from 0 to 9).

I am Googling since a few hours to lookup for suggersions or pre-made solutions.