diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-04-13 02:21:03 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-04-13 02:21:03 +0200 |
commit | c4782818f49521c0783a197375bce701fb0a9572 (patch) | |
tree | 27f841644ce9a2083f9a2c0ab92caab5517e9aa8 /sys/lib/python/hashlib.py | |
parent | a5268a54131f53b51e778a7f6157da53cdbe3142 (diff) |
python: make hashlib.py fallback to openssl in case of old python binary
Diffstat (limited to 'sys/lib/python/hashlib.py')
-rw-r--r-- | sys/lib/python/hashlib.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/lib/python/hashlib.py b/sys/lib/python/hashlib.py index 06cc67c21..2a09dc344 100644 --- a/sys/lib/python/hashlib.py +++ b/sys/lib/python/hashlib.py @@ -51,14 +51,22 @@ More condensed: """ -import _sechash - -md5 = _sechash.md5 -sha1 = _sechash.sha1 -sha224 = _sechash.sha224 -sha256 = _sechash.sha256 -sha384 = _sechash.sha384 -sha512 = _sechash.sha512 +try: + import _sechash + md5 = _sechash.md5 + sha1 = _sechash.sha1 + sha224 = _sechash.sha224 + sha256 = _sechash.sha256 + sha384 = _sechash.sha384 + sha512 = _sechash.sha512 +except ImportError: + import _hashlib + md5 = _hashlib.openssl_md5 + sha1 = _hashlib.openssl_sha1 + sha224 = _hashlib.openssl_sha224 + sha256 = _hashlib.openssl_sha256 + sha384 = _hashlib.openssl_sha384 + sha512 = _hashlib.openssl_sha512 algs = dict() for a in [md5, sha1, sha224, sha256, sha384, sha512]: |