micropython / micropython-lib

Core Python libraries ported to MicroPython
Other
2.4k stars 997 forks source link

HMAC AttributeError #384

Closed cositotito closed 2 years ago

cositotito commented 4 years ago

hello all, I have a problem when using 'import hmac' and I try to use it on my esp32

How can I use the new or remove this error? I would appreciate the help

cositotito commented 4 years ago

import hmac import hashlib import time import urequests import json

secret="345fg-dfg" word="536" signature = hmac.new(secret, word.encode(), digestmod=hashlib.sha256).hexdigest().upper()

Traceback (most recent call last): File "", line 1, in File "/lib/hmac.py", line 149, in new File "/lib/hmac.py", line 63, in init AttributeError: 'sha256' object has no attribute 'digest_size'

mvo5 commented 3 years ago

Fwiw, I ran into the same issue and pushed a PR that fixes this for me. Let's see what the code review says.

dpgeorge commented 2 years ago

Should be fixed by f95260d7e3c123a8b1907ded095e4c25e4251085