kopia lustrzana https://github.com/micropython/micropython-lib
hmac: Fix passing in a string for digestmod argument.
The built-in `hashlib` module does not have a `.new` method (although the Python version in this repository does).pull/789/head
rodzic
35d41dbb0e
commit
ddb1a27957
|
@ -17,7 +17,7 @@ class HMAC:
|
|||
make_hash = digestmod # A
|
||||
elif isinstance(digestmod, str):
|
||||
# A hash name suitable for hashlib.new().
|
||||
make_hash = lambda d=b"": hashlib.new(digestmod, d) # B
|
||||
make_hash = lambda d=b"": getattr(hashlib, digestmod)(d)
|
||||
else:
|
||||
# A module supporting PEP 247.
|
||||
make_hash = digestmod.new # C
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
metadata(version="3.4.3")
|
||||
metadata(version="3.4.4")
|
||||
|
||||
module("hmac.py")
|
||||
|
|
|
@ -8,7 +8,7 @@ import hashlib
|
|||
|
||||
msg = b"zlutoucky kun upel dabelske ody"
|
||||
|
||||
dig = hmac.new(b"1234567890", msg=msg, digestmod=hashlib.sha256).hexdigest()
|
||||
dig = hmac.new(b"1234567890", msg=msg, digestmod="sha256").hexdigest()
|
||||
|
||||
print("c735e751e36b08fb01e25794bdb15e7289b82aecdb652c8f4f72f307b39dad39")
|
||||
print(dig)
|
||||
|
|
Ładowanie…
Reference in New Issue