I am trying to generate a 256-bit output using Argon2 password hasher. The function take s a hash_len parameter which I set to 32. Thinking that 32 bytes equals 256 bits.
Why does Argon2 output the length of 43, and not 32?
from argon2 import PasswordHasher
password = "abc123"
salt = b'b8b17dbde0a2c67707342c459f6225ed'
hasher = PasswordHasher(
salt_len=len(salt),
hash_len=32,
)
hasherOutput = hasher.hash(password, salt = salt)
hash = hasherOutput.split('$')[-1]
print(len(hash))
# Output: 43
# Expected: 32
The problem was that like the comments pointed out, the string was indeed Base64-encoded. Trying to decode it using
binascii.a2b_base64()failed until I appended "==" to the input.