mirror of
https://github.com/Legrandin/pycryptodome.git
synced 2025-11-03 15:11:38 +00:00
Simplify wrapper, as digest_size is known in advance each time.
This commit is contained in:
parent
9620229917
commit
dd3f0007c5
3 changed files with 9 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue