Mercurial > hgrepos > Python > apps > py-cutils
diff shasum.py @ 70:7844f5136214
Use "hmac.compare_digest()" where available
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 26 Feb 2022 17:48:20 +0100 |
| parents | a23371a8780f |
| children | 29fb33aa639a |
line wrap: on
line diff
--- a/shasum.py Sat Feb 26 17:31:40 2022 +0100 +++ b/shasum.py Sat Feb 26 17:48:20 2022 +0100 @@ -27,6 +27,10 @@ import binascii import errno import hashlib +try: + from hmac import compare_digest +except ImportError: + compare_digest = None import io try: import mmap @@ -208,7 +212,10 @@ return False else: return False - return given_digest == exd + if compare_digest: + return compare_digest(given_digest, exd) + else: + return given_digest == exd def verify_digests_with_checklist(opts):
