I have a pico and i'm using the micropython port for rp2 board, trying to use uhashlib.sha1(), but it gives error: module object has no attribute sha1.
It seems that the official firmware has only sha256 implemented.
I'm trying to compile micropython from source, editing the file /micropython/ports/rp2/mpconfigport.h By default only #define MICROPY_PY_UHASHLIB (1) is present; i tried to add #define MICROPY_PY_UHASHLIB_SHA1 (1) but the compiling process results in this error:
Code: Select all
Building C object CMakeFiles/firmware.dir/pico/micropython/extmod/moduhashlib.c.obj
In file included from /pico/micropython/py/mpstate.h:35:0,
from /pico/micropython/py/runtime.h:29,
from /pico/micropython/extmod/moduhashlib.c:30:
/pico/micropython/extmod/moduhashlib.c:249:60: error: 'uhashlib_sha1_digest' undeclared here (not in a function); did you mean 'uhashlib_sha256_digest'?
STATIC MP_DEFINE_CONST_FUN_OBJ_1(uhashlib_sha1_digest_obj, uhashlib_sha1_digest);
^
/pico/micropython/py/obj.h:337:42: note: in definition of macro 'MP_DEFINE_CONST_FUN_OBJ_1'
{{&mp_type_fun_builtin_1}, .fun._1 = fun_name}
^~~~~~~~
/pico/micropython/extmod/moduhashlib.c:260:17: error: 'uhashlib_sha1_make_new' undeclared here (not in a function); did you mean 'uhashlib_sha256_make_new'?
.make_new = uhashlib_sha1_make_new,
^~~~~~~~~~~~~~~~~~~~~~
uhashlib_sha256_make_new
/pico/micropython/extmod/moduhashlib.c:171:17: error: 'uhashlib_sha1_update' used but never defined [-Werror]
STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg);
^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [CMakeFiles/firmware.dir/build.make:2219: CMakeFiles/firmware.dir/pico/micropython/extmod/moduhashlib.c.obj] Error 1
Adding external libraries?