Skip to content

HMAC AttributeError #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cositotito opened this issue Apr 24, 2020 · 3 comments
Closed

HMAC AttributeError #384

cositotito opened this issue Apr 24, 2020 · 3 comments

Comments

@cositotito
Copy link

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

  • before using it, I install it and it installs correctly, the code is the following:
    import upip
    upip.install ("hmac")

  • the code is the following to use hmac:
    digest = hmac.new (s.decode ("base64"), a, hashlib.sha3_256) .digest ()

  • the error that prints to me on my console:
    Traceback (most recent call last):
       File "", line 1, in
    AttributeError: 'module' object has no attribute 'new'

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

@cositotito
Copy link
Author

  • Code example.py:

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()

  • return Error:

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
Copy link

mvo5 commented Jul 21, 2021

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
Copy link
Member

dpgeorge commented Aug 8, 2022

Should be fixed by f95260d

@dpgeorge dpgeorge closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants