ハッシュ/暗号
Scrypt Hash + Verify
scrypt(RFC 7914、メモリ依存型KDF)でパスワードをハッシュ化し、既存ハッシュとの照合も可能。
Scrypt (RFC 7914) was one of the first memory-hard password-hashing algorithms: it deliberately requires a lot of RAM, not just CPU time, to make parallel brute-forcing on GPUs and ASICs harder.
How to use it
- Hash: enter a password and tune the parameters (N — memory cost, r — block size, p — parallelism) to get a hash.
- Verify: paste a password and an existing scrypt hash to check whether they match.
- Every hash uses a fresh random salt, so the same password produces a different hash each time.
Common uses
- Checking that a backend correctly hashes passwords with scrypt before storing them.
- Generating a test scrypt hash for fixtures or seed data during development.
- Comparing scrypt against bcrypt and Argon2 when choosing a hashing algorithm for a new project.
Things to keep in mind
The N parameter (memory cost) increases both required memory and compute time exponentially — tune it to your server's actual capacity.
Scrypt has been superseded by Argon2 (the official Password Hashing Competition winner) as the recommended choice for new systems, though scrypt itself still isn't considered unsafe.
よくある質問
scryptはbcryptやPBKDF2とどう違いますか?
Scryptは意図的にメモリハードかつCPU集約的であり、主にCPUベースのブルートフォースにしか耐性のないbcryptやPBKDF2に比べ、GPUやカスタムASICハードウェアでの解読をはるかに高コストにします。
N、r、pパラメータは何を制御しますか?
NはCPU/メモリコストを設定し(2のべき乗である必要があります)、rは操作ごとのメモリ使用に影響するブロックサイズを設定し、pは並列度を設定します。いずれかを増やすと、正当な利用と攻撃の両方のリソースコストが上がります。
Argon2と比べて、scryptは今でも良い選択ですか?
Scryptは依然として堅実で実績がありますが、メモリとサイドチャネル耐性をより細かく制御できるため、新規システムには一般的にArgon2(Password Hashing Competitionの勝者)が推奨されます。
scryptは実際にどれくらいのメモリを消費しますか?
1回の計算につきおおよそ128 × N × rバイトです。典型的なパラメータ(N=16384、r=8)では1ハッシュあたり約16メガバイトになります——1回のログインでは些細な量ですが、サーバーで数千件の同時認証がある場合は無視できません。
scryptはパスワードハッシュ化以外にどこで使われていますか?
scryptは一部の暗号通貨(Litecoinなど)でproof-of-workアルゴリズムとして知られています。SHA-256を使うビットコインに特徴的な専用ASICでのマイニングへの耐性を得るために、あえて選ばれました。