ref: c4782818f49521c0783a197375bce701fb0a9572
parent: a5268a54131f53b51e778a7f6157da53cdbe3142
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Apr 12 22:21:03 EDT 2016
python: make hashlib.py fallback to openssl in case of old python binary
--- a/sys/lib/python/hashlib.py
+++ b/sys/lib/python/hashlib.py
@@ -51,14 +51,22 @@
"""
-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]: