lundi 2 septembre 2019

Generate a deterministic random number from a timestamp

I’m generating IDs with a timestamp part (48 bits) and a random part (72 bits) so that the IDs are ordered but don’t clash. When serializing the IDs to a human readable format I want the IDs to appear random. The serialization will need to be reversible since I need to deserialize an ID back into its ordered timestamp/random form.

I don’t need the serialization to be secure, it’s ok if it’s easily reverse-engineered, I just want the appearance of a randomly generated ID.

Example of some IDs in hexadecimal that I want to encode:

16CF304F7B3D5CBED3977C90DD6F5
16CF30578DCBCF35A0585A4FF6DE0
16CF30599F53BB7E61791824D6345




Aucun commentaire:

Enregistrer un commentaire