Skip to content

Commit 7095aa4

Browse files
committed
remove rationale comment for OpenSSL SHA-1
In this commit, we move the rationale for using OpenSSL-based SHA-1 instead of its HACL* implementation from the code to this note. HACL*-based SHA-1 is 2x faster than its OpenSSL implementation for creating the hash object via `h = sha1(..., usedforsecurity=False)` but `h.digest()` is almost 3x slower. Unlike HACL* MD5, HACL*-based SHA-1 is slower than its OpenSSL-based implementation, whence the choice of `hashlib.sha1` over `_sha1.sha1`.
1 parent cff86e9 commit 7095aa4

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

‎Lib/uuid.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,8 +747,6 @@ def uuid5(namespace, name):
747747
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
748748
if isinstance(name, str):
749749
name = bytes(name, "utf-8")
750-
# OpenSSL-based SHA-1 is slightly faster than its HACL* version,
751-
# and 'import X; X.Y' is slightly faster than 'from X import Y'.
752750
import hashlib
753751
h = hashlib.sha1(namespace.bytes + name, usedforsecurity=False)
754752
int_uuid_5 = int.from_bytes(h.digest()[:16])

0 commit comments

Comments
 (0)