← Cryptography guide

K060 / Hashes, MACs and key derivation

scrypt

scrypt key derivation · Survey date 2026-12-05

A memory-hard key derivation function deriving a secret key from a secret string such as a password.

CRYPTOGRAPHY LAB / K060

Cryptography Lab · scrypt

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Toy educational example

scrypt (RFC 7914; r=p=1, dkLen=64)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
A memory-hard key derivation function deriving a secret key from a secret string such as a password. Source document ↗
Classification and reversibility
One-way KDF/hash-derived key function; no decryption or decoding. Source document ↗
Key or secret requirements
Needs password P, salt S, costs N/r/p and output key length. Source document ↗
Operating principle and structure
ROMix-based memory-hard structure using large array V. Source document ↗
Key size, block size and parameters
N CPU/memory cost, r block size, p parallelism and output key length. Source document ↗
Security strength and recommendation
Memory hardness mitigates custom hardware attacks; recommended when Argon2 unavailable. Source document ↗
Known attacks and vulnerabilities
Not confirmed in the survey
Standards and certification
Specified in IETF RFC 7914 (Informational). Source document ↗
Typical uses
Password storage/derivation, some cryptocurrency PoW/BIP38 and file encryption tools. Source document ↗
Implementations, libraries and tools
libsodium, Python cryptography, JS scryptsy and Tarsnap scrypt utility. Source document ↗
Decryption or decoding
KDF itself cannot decrypt. Utility-encrypted data can be decrypted with scrypt dec and same password; verify passwords by rederivation and comparison. Source document ↗
Advantages
Memory-hard design increases custom hardware/ASIC/GPU attack cost. Source document ↗
Limitations and cautions
Recommended only if Argon2 unavailable; parameters can impose substantial memory/time costs. Source document ↗
Distinguishing encryption, encoding and hashing
Irreversible KDF deriving fixed-length key bytes from password, not encryption or encoding. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Choose password, random salt, N/r/p (e.g. N=2^14,r=8,p=1) and output length. Same inputs/parameters yield same key; compare stored verifier or use key for separate symmetric encryption.

Procedure

Derive with password, salt, N/r/p and output length. Store salt and parameters; verify by rederivation and secure comparison. scrypt itself cannot decrypt; only decrypt data encrypted with a derived key using the relevant utility.

Scenario

Store service passwords as scrypt-derived values with salt/N/r/p and recompute at verification. Password-based file encryption derives key then uses symmetric cipher; rederive at decryption.

Pitfalls and alternatives

Do not mistake scrypt for encryption/encoding or store/decrypt passwords directly. Avoid insufficient parameters; prefer Argon2id if available.

References