

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Encrypting Data at Rest
incomplete
2: Key Management and Rotation
incomplete
3: Password KDFs
incomplete
4: Salts
incomplete
5: Argon2 Parameters
incomplete
6: Encrypted Files
incomplete
7: Secure Database Practices
incomplete
8: Personally Identifiable Information
incomplete
9: Financial Data
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Passwords should never be stored in plaintext... but even hashing them isn't always enough.
If attackers steal your password hashes, they can test guesses offline on their own hardware with no rate limit. A fast general-purpose hash function like SHA-256 lets them rip through candidates, making SHA-256 a terrible password-storage choice.
Click to play video
A password key derivation function is designed to be expensive. For example, Argon2id consumes both CPU time and memory, making large batches of offline guesses much more costly.
Go's golang.org/x/crypto/argon2 package exposes the low-level derivation function. Bearly Secure must generate a random salt and derive the key explicitly:
salt := make([]byte, 16)
if _, err := rand.Read(salt); err != nil {
return "", err
}
derivedKey := argon2.IDKey([]byte(password), salt, 2, 19*1024, 1, 32)
The provided helpers in internal/auth/passwords/argon2id.go handle the storage format. They encode the algorithm, version, parameters, salt, and derived key into one string, then strictly parse those values during verification. The parser also rejects malformed or excessive parameters before they reach the expensive derivation function.
Suppose your app already has users whose passwords are stored as 64-character SHA-256 hashes. Ruh-roh. Adding an Argon2-only verifier would lock them out!
You'll need to verify both formats during the transition, but create only Argon2id hashes for new or changed passwords:
$argon2id$... value carries the salt and parameters needed for Argon2id verification.Bearly Secure stores passwords with fast SHA-256 hashes. Adopt Argon2id for every new or changed password without breaking existing accounts.
Run and submit the CLI tests from the project root.