stef/pysodium

crypto_generichash ValueError

Closed this issue · 2 comments

# 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

It looks like the k was wrong

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

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