When using uuid5 instead of sha1, the collision probability is the same?

I need to create a unique hash, but I would like to preserve the 'uuid' structure , so I'm thinking of using something like:

uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')

Instead of sha1:

hashlib.sha1('python.org').hexdigest()

But I wonder if they offer the same chance of collision, or maybe uuid5 is more prone to collisions because of the namespace.

+4
source share
1 answer

The simple answer is: avoid.

UUID5 truncates the hash to 128 bits. While 128 bits will be absolutely good for most applications, the real problem is that you are using the deprecated and deprecated hashing algorithm in SHA1, and you make it difficult to change it later.

: , .

, SHA2 SHA3 , .

+1

All Articles