1

Not sure if it is the right output but when I hash a password with argon in java, i get the output:

$argon2i$v=19$m=512,t=2,p=2$J1w6n04CBSEA8p0cCqeK7A$tb1ihqduhONYZN0+ldKkw980Y7h7ZJ2OcDTsXyIMibo

while python gives me:

argon2$argon2i$v=19$m=512,t=2,p=2$TjZiM3ZTdGFIQUlZ$CocCpAIXQc722ndqkFZWxw

the parameters seem the same: i, 512, 2, p =2

Any argon2 guru who can tell me how I can have the same length output? Prefer playing with the java since it is a simple ussd app.

Nie Selam
  • 1,343
  • 2
  • 24
  • 56

1 Answers1

0

After the p=2 in the string, there is a dollar sign. The string between this dollar sign and the next dollar sign is the salt of the hash. After the second dollar sign is the actual key that has been derived by Argon2. In the Java example, (after being base64 decoded), the hash length is 32. However, in Python, the hash length is 16 (which is the default in Python). So, in Python, if you did:

import argon2

argon2.hash_password(b"Password",memory_cost=512,time_cost=2,parallelism=2,hash_len=32)

Then you will have the same length hash as in the Java example. Also, if you specify the same salt for both the Python and Java implementations, then the hashes should be identical to each other (given that the parameters are the same between the two).

ndrwnaguib
  • 5,623
  • 3
  • 28
  • 51
SamG101
  • 488
  • 1
  • 7
  • 18