stef / pysodium

wrapper for libsodium providing high level crypto primitives
Other
130 stars 50 forks source link

crypto_generichash ValueError #103

Closed markuman closed 2 years ago

markuman commented 2 years ago
# crypto_generichash(m, k=b'', outlen=crypto_generichash_BYTES)
genericHash = pysodium.crypto_generichash(
    m=_password + passwordSalt,
    k=bytes(genericHashKey, 'utf-8'),
    outlen=pysodium.crypto_generichash_BYTES_MAX
)

results in

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/pysodium/__init__.py", line 441, in crypto_generichash
    __check(sodium.crypto_generichash(buf, ctypes.c_size_t(outlen), m, ctypes.c_ulonglong(len(m)), k, ctypes.c_size_t(len(k))))
  File "/usr/lib/python3/dist-packages/pysodium/__init__.py", line 251, in __check
    raise ValueError
ValueError
markuman commented 2 years ago

It looks like the k was wrong

    k=bytes(bytearray.fromhex(genericHashKey)),
stef commented 2 years ago

glad you figured it out. i just wanted to have a look myself.