Message352270
The hashlib module / PEP 452 and OpenSSL use slightly different conventions for hashing algorithm names. The old and common algorithms like md5 to sha512 use the same strings (all lower case, no dashes or underscores). But new algorithms like sha3_512, shake, sha512_256, and blake2 use different conventions.
The inconsistency bloats the list of available algorithms. Also the builtin OpenSSL constructor does not support Python's preferred names.
>>> import hashlib, _hashlib
>>> sorted(hashlib.algorithms_available)
['blake2b', 'blake2b512', 'blake2s', 'blake2s256', 'md4', 'md5', 'md5-sha1', 'ripemd160', 'sha1', 'sha224', 'sha256', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512', 'sha384', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'sha512', 'sha512-224', 'sha512-256', 'shake128', 'shake256', 'shake_128', 'shake_256', 'sm3', 'whirlpool']
>>> _hashlib.new("sha3_512")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unsupported hash type
>>> _hashlib.new("sha3-512")
<sha3-512 HASH object @ 0x7f1387890840>
I propose to normalize names to Python standard names for HASH.name, repr, list of available algorithms, and for the new() constructor. |
|
Date |
User |
Action |
Args |
2019-09-13 09:50:32 | christian.heimes | set | recipients:
+ christian.heimes, gregory.p.smith |
2019-09-13 09:50:32 | christian.heimes | set | messageid: <1568368232.54.0.0384008471773.issue38153@roundup.psfhosted.org> |
2019-09-13 09:50:32 | christian.heimes | link | issue38153 messages |
2019-09-13 09:50:32 | christian.heimes | create | |
|