micropython / micropython-esp32

Old port of MicroPython to the ESP32 -- new port is at https://github.com/micropython/micropython
MIT License
673 stars 216 forks source link

SHA1 and uhashlib #178

Closed rdagger closed 6 years ago

rdagger commented 6 years ago

I tried to import uhashlib and it doesn't appear to be implemented. I'm using the latest daily build: esp32-20170911-v1.9.2-270-g14fb53e0.bin Is there currently any support for sha1?

MrSurly commented 6 years ago
MicroPython v1.9.2-270-g14fb53e0 on 2017-09-11; ESP32 module with ESP32
Type "help()" for more information.
>>> import binascii, hashlib
>>> hash = hashlib.sha1('mango')
>>> binascii.hexlify(hash.digest()) 
b'934aae49f648ed870c9c421829f4cece6643cf86'
>>> 

Works for me, and the hash is correct. Can you send any code that isn't working?

rdagger commented 6 years ago

Thanks!

MrSurly commented 6 years ago

If this is resolved, please close.

rdagger commented 6 years ago

The issue I had was the docs refer to the library as uhashlib instead of just hashlib. Thanks again.

MrSurly commented 6 years ago

I noticed that as well. All of the libraries that start with 'u' should import without the 'u'.

I think that this might be a legitimate issue with aliasing. I'll look into it.

On Sep 11, 2017 3:13 PM, "rdagger" notifications@github.com wrote:

The issue I had was the docs https://docs.micropython.org/en/latest/pyboard/library/uhashlib.html refer to the library as uhashlib instead of just hashlib. Thanks again.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/micropython/micropython-esp32/issues/178#issuecomment-328674092, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYHCFxSYxqGUn-22n0vjp--0Z_ohWXfks5shbCkgaJpZM4PTbfa .

nickzoic commented 6 years ago

Yeah, just rebuilt and uhashlib won't import

MicroPython v1.9.2-270-g14fb53e0 on 2017-09-12; ESP32 module with ESP32
Type "help()" for more information.
>>> import uhashlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'uhashlib'
>>> import hashlib
>>>

It also doesn't appear in help('modules')

OK, so the new esp32-specific module was in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS but wasn't in MICROPY_PORT_BUILTIN_MODULES, is all.

MrSurly commented 6 years ago

@nickzoic Is this still an issue?

nickzoic commented 6 years ago

Ok, merged #179 and closing this ...