logoalt Hacker News

MarekKnapekyesterday at 11:31 AM2 repliesview on HN

Is there a way to have benefits of both? Version 7 for better database clustering. And version 4 for complete randomness? So users can not inference nothing from the id? I have an idea: Use version 7 internally, then scramble it before sending to the user. Scrambling could be done by the database or by the server application. It could be as simple as XOR with some 128bit constant, or as resilient as AES encryption. Of course you also need to do unscrambling of IDs coming from users.


Replies

8organicbitsyesterday at 12:09 PM

Others agree. Check out uuidv47

https://github.com/stateless-me/uuidv47

grey-areayesterday at 11:46 AM

If privacy is the main concern (as it is in most usage of UUIDs) you could just encrypt the integer primary key instead with something like feistel and avoid the performance problems of UUIDs while still having opaque public identifiers.