Mercurial > hgrepos > Python > apps > py-cutils
changeset 85:d445534b80bb
Get the factory for blake2b and blake2s indirectly: prepare for blake2-256
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 20 Apr 2022 23:15:55 +0200 |
| parents | 163de6dd6e05 |
| children | fd1cfd1b0f9d |
| files | cutils/shasum.py |
| diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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:
