# HG changeset patch # User Franz Glasner # Date 1650489355 -7200 # Node ID d445534b80bb82bfd0e7a9d70d99f8328d13c3d0 # Parent 163de6dd6e059ee71f8e501837ba1930491eb88d Get the factory for blake2b and blake2s indirectly: prepare for blake2-256 diff -r 163de6dd6e05 -r d445534b80bb cutils/shasum.py --- a/cutils/shasum.py Wed Apr 20 17:03:57 2022 +0200 +++ b/cutils/shasum.py Wed Apr 20 23:15:55 2022 +0200 @@ -380,6 +380,16 @@ return None +def get_blake2b(): + """Get the factory for blake2b""" + return hashlib.blake2b + + +def get_blake2s(): + """Get the factory for blake2s""" + return hashlib.blake2s + + def argv2algo(s): """Convert a command line algorithm specifier into a tuple with the type/factory of the digest and the algorithms tag for output purposes. @@ -411,9 +421,9 @@ elif s in ("3-512", "sha3-512"): return (hashlib.sha3_512, "SHA3-512") elif s in ("blake2b", "blake2b-512"): - return (hashlib.blake2b, "BLAKE2b") + return (get_blake2b(), "BLAKE2b") elif s in ("blake2s", "blake2s-256"): - return (hashlib.blake2s, "BLAKE2s") + return (get_blake2s(), "BLAKE2s") elif s == "md5": return (hashlib.md5, "MD5") else: @@ -450,9 +460,9 @@ elif s == "SHA3-512": return hashlib.sha3_512 elif s == "BLAKE2b": - return hashlib.blake2b + return get_blake2b() elif s == "BLAKE2s": - return hashlib.blake2s + return get_blake2s() elif s == "MD5": return hashlib.md5 else: