Skip to content

Password derivation

Read the implementations in Python and C.

Human-chosen passwords have much less entropy than a randomly generated encryption key. Argon2id makes each password guess cost both memory and time. These small standalone examples use the second recommended profile in RFC 9106 and generate a new 16-byte random salt on every run.

build/password_kdf
uv run python examples/password_kdf.py

Both programs print the salt on the first line and a 32-byte verifier on the second, in hexadecimal. The public sample password is classroom password. Different salts should produce different outputs. Tests independently verify both outputs with PyCA's Argon2id verification API.

Parameter Value
Memory 65,536 KiB (64 MiB total)
Iterations 3
Lanes 4
Argon2 version 1.3

An application storing a password verifier also stores the algorithm, parameters and salt so it can repeat verification and upgrade parameters. Choose the cost against the deployment's available memory and latency budget. A stored verifier is sensitive because it allows offline guessing. Keep any key used for encryption separate from a stored password verifier.

Read RFC 9106, section 4.