python: make hashlib.py fallback to openssl in case of old python binary
This commit is contained in:
parent
a5268a5413
commit
c4782818f4
1 changed files with 16 additions and 8 deletions
|
@ -51,14 +51,22 @@ More condensed:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
import _sechash
|
import _sechash
|
||||||
|
|
||||||
md5 = _sechash.md5
|
md5 = _sechash.md5
|
||||||
sha1 = _sechash.sha1
|
sha1 = _sechash.sha1
|
||||||
sha224 = _sechash.sha224
|
sha224 = _sechash.sha224
|
||||||
sha256 = _sechash.sha256
|
sha256 = _sechash.sha256
|
||||||
sha384 = _sechash.sha384
|
sha384 = _sechash.sha384
|
||||||
sha512 = _sechash.sha512
|
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()
|
algs = dict()
|
||||||
for a in [md5, sha1, sha224, sha256, sha384, sha512]:
|
for a in [md5, sha1, sha224, sha256, sha384, sha512]:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue