summaryrefslogtreecommitdiff
path: root/lib/Crypto/Hash
diff options
context:
space:
mode:
authorLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2011-02-07 23:18:12 +0100
committerLegrandin <gooksankoo@hoiptorrow.mailexpire.com>2011-02-07 23:18:12 +0100
commitdd3f0007c546ff3f9258719226cb065a30155b2c (patch)
tree0fe773bd8495ccd3bbbad9202a23f10882adab3f /lib/Crypto/Hash
parent96202299179059138bb4c81873a8e8c61bb4ee3c (diff)
downloadpycrypto-dd3f0007c546ff3f9258719226cb065a30155b2c.tar.gz
Simplify wrapper, as digest_size is known in advance each time.
Diffstat (limited to 'lib/Crypto/Hash')
-rw-r--r--lib/Crypto/Hash/MD5.py6
-rw-r--r--lib/Crypto/Hash/SHA.py6
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/Crypto/Hash/MD5.py b/lib/Crypto/Hash/MD5.py
index d9cf4b4..366cce2 100644
--- a/lib/Crypto/Hash/MD5.py
+++ b/lib/Crypto/Hash/MD5.py
@@ -38,17 +38,17 @@ def new(data=""):
obj = Wrapper(hashFactory, data)
obj.oid = oid
obj.new = globals()['new']
+ if not hasattr(obj, 'digest_size'):
+ obj.digest_size = digest_size
return obj
try:
# The md5 module is deprecated in Python 2.6, so use hashlib when possible.
import hashlib
hashFactory = hashlib.md5
- digest_size = new().digest_size
except ImportError:
import md5
hashFactory = md5
- if hasattr(md5, 'digestsize'):
- digest_size = md5.digestsize
+digest_size = 16
diff --git a/lib/Crypto/Hash/SHA.py b/lib/Crypto/Hash/SHA.py
index d77a3c2..c806f09 100644
--- a/lib/Crypto/Hash/SHA.py
+++ b/lib/Crypto/Hash/SHA.py
@@ -38,17 +38,17 @@ def new(data=""):
obj = Wrapper(hashFactory, data)
obj.oid = oid
obj.new = globals()['new']
+ if not hasattr(obj, 'digest_size'):
+ obj.digest_size = digest_size
return obj
try:
# The sha module is deprecated in Python 2.6, so use hashlib when possible.
import hashlib
hashFactory = hashlib.sha1
- digest_size = new().digest_size
except ImportError:
import sha
hashFactory = sha
- if hasattr(sha, 'digestsize'):
- digest_size = sha.digestsize
+digest_size = 20