Answer the question
In order to leave comments, you need to log in
Base64UID vs UUID?
I don't quite understand the code in both the second and first cases
https://github.com/gpslab/base64uid/blob/master/sr...
vs
https://github.com/ramsey/uuid/blob/master/ src/Uuid.php
Which code is more reliable? Which one will generate 101% unique values?
To generate a lightweight unique key.
Answer the question
In order to leave comments, you need to log in
To date, there are five versions of UUID.
V1 based on key generation time stamp and device MAC address
V2 Reserved for DCE security standard. Its specification itself is not described in the UUID standard, therefore it is usually referred to the DCE 1.1
V3 specification based on the key generation timestamp and the md5 hash of the namespace alias.
V4is based on the value of pseudo-random generators. While this somewhat increases the range of values, and eliminates the ability to uniquely identify the origin of the key, it also creates the possibility of collisions, especially for those cases where the pseudo-random value generator is not "powerful" enough. For the same reason, it is recommended to use a common "source" when generating random values in distributed systems.
V5 is the same as v3 but uses sha1 as the hash function, which greatly increases the complexity of identifying the origin of the key.
Which version of the key to use is your choice. If this is not a distributed system and the keys are generated in one place, then I would prefer v4.
As for specific implementations, in the php world, Ramsey's implementation is considered the de facto standard.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question