Argon2 is the winner of the Password Hashing Competition (2015) and is currently the recommended algorithm for password hashing. It offers configurable memory, time, and parallelism parameters with three variants for different use cases.
argon2id(password, salt, time_cost, memory_cost, parallelism)
time_cost: Number of iterations
memory_cost: Memory usage in KB
parallelism: Number of parallel threads
# Hash format:
$argon2id$v=19$m=65536,t=3,p=4$c2FsdHNhbHQ$hash
# Python with argon2-cffi
from argon2 import PasswordHasher
ph = PasswordHasher(
time_cost=3,
memory_cost=65536, # 64MB
parallelism=4
)
# Hash password
hash = ph.hash("secretpassword")
# Verify password
try:
ph.verify(hash, "secretpassword")
except VerifyMismatchError:
print("Invalid password")