diff options
author | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2011-10-10 15:11:42 -0400 |
---|---|---|
committer | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2011-10-10 16:05:23 -0400 |
commit | 5cdb029401da4ef3d29dfe997135fc4270dacf83 (patch) | |
tree | 9bcf2bee719b56b5fbcc38c9d265c9ac2a83e929 | |
parent | 7e490d9b3ae75bea53d600cff6cef9f9dec08003 (diff) | |
download | pycrypto-5cdb029401da4ef3d29dfe997135fc4270dacf83.tar.gz |
SHA224/384/512: Py3k compatibility
-rw-r--r-- | lib/Crypto/Hash/SHA224.py | 7 | ||||
-rw-r--r-- | lib/Crypto/Hash/SHA384.py | 7 | ||||
-rw-r--r-- | lib/Crypto/Hash/SHA512.py | 7 |
3 files changed, 12 insertions, 9 deletions
diff --git a/lib/Crypto/Hash/SHA224.py b/lib/Crypto/Hash/SHA224.py index e2a6876..7499a85 100644 --- a/lib/Crypto/Hash/SHA224.py +++ b/lib/Crypto/Hash/SHA224.py @@ -24,8 +24,9 @@ __revision__ = "$Id$" __all__ = ['new', 'digest_size'] -import hashlib -def new(data=""): - return hashlib.sha224(data) +from hashlib import sha224 # This will only work in versions of Python that support SHA224 +from Crypto.Util.py3compat import * +def new(data=b("")): + return sha224(data) digest_size = new().digest_size block_size = 64 diff --git a/lib/Crypto/Hash/SHA384.py b/lib/Crypto/Hash/SHA384.py index 8d0fa30..248955d 100644 --- a/lib/Crypto/Hash/SHA384.py +++ b/lib/Crypto/Hash/SHA384.py @@ -24,8 +24,9 @@ __revision__ = "$Id$" __all__ = ['new', 'digest_size'] -import hashlib -def new(data=""): - return hashlib.sha384(data) +from hashlib import sha384 # This will only work in versions of Python that support SHA384 +from Crypto.Util.py3compat import * +def new(data=b("")): + return sha384(data) digest_size = new().digest_size block_size = 128 diff --git a/lib/Crypto/Hash/SHA512.py b/lib/Crypto/Hash/SHA512.py index f6c4787..38bd957 100644 --- a/lib/Crypto/Hash/SHA512.py +++ b/lib/Crypto/Hash/SHA512.py @@ -24,8 +24,9 @@ __revision__ = "$Id$" __all__ = ['new', 'digest_size'] -import hashlib -def new(data=""): - return hashlib.sha512(data) +from hashlib import sha512 # This will only work in versions of Python that support SHA512 +from Crypto.Util.py3compat import * +def new(data=b("")): + return sha512(data) digest_size = new().digest_size block_size = 128 |