ハッシュ/暗号
Argon2 Hash + Verify
Argon2(Password Hashing Competitionの優勝方式、RFC 9106)でパスワードをハッシュ化 — d/i/idの3種類のバリアントに対応し、既存ハッシュとの照合も可能。
Argon2 is the Password Hashing Competition winner and the algorithm recommended in RFC 9106 for hashing passwords. Unlike bcrypt, it deliberately demands a lot of memory, not just CPU time, which makes attacks on specialized hardware (GPUs, ASICs) much harder.
How to use it
- Hash: enter a password, pick a variant (Argon2d, Argon2i, or Argon2id), and set the parameters (memory, iterations, parallelism) to get a hash.
- Verify: paste a password and an existing Argon2 hash to check whether they match, without hashing manually yourself.
- Argon2id is the recommended default for most applications — it combines the strengths of Argon2i and Argon2d.
Common uses
- Checking that a backend generates correct Argon2 hashes with the expected parameters before a release.
- Tuning memory and iteration parameters to fit within a server's response-time budget (typically 250-500ms).
- Comparing Argon2 against bcrypt or PBKDF2 when choosing an algorithm for a new project.
Things to keep in mind
The memory parameter is Argon2's main defense: the more memory hashing requires, the more expensive it is for an attacker to parallelize an attack on a GPU with limited fast memory per chip.
Argon2id is recommended for most cases: Argon2i resists side-channel attacks better, Argon2d resists GPU attacks better, and id combines both approaches.
よくある質問
パスワードにMD5やSHA-256のような古いハッシュではなくArgon2が推奨されるのはなぜですか?
Argon2は意図的に低速でメモリを大量に消費するよう設計されており、総当たり攻撃やGPU/ASICによる解読を大幅に高コストにします。一方、MD5やSHA-256のような高速な汎用ハッシュはパスワード保存には不向きです。
メモリ、反復回数、並列度のパラメータは何を制御しますか?
メモリコストは各ハッシュ試行に必要なRAM量を、反復回数は実行するパス数を、並列度はスレッド数を設定します。いずれかを増やすと解読コストは上がりますが、ハッシュ処理は遅くなります。
どのArgon2バリアント(d、i、id)を使うべきですか?
パスワードハッシュにはArgon2idがデフォルトで推奨されます。Argon2iのサイドチャネル攻撃への耐性とArgon2dのGPU解読への耐性を組み合わせているためです。
Argon2はどのようにして標準になったのですか?
Argon2は2015年のPassword Hashing Competitionで優勝しました——これはパスワードハッシュ化に最適なアルゴリズムを見つけることを目的とした、暗号学者による公開コンペティションです。それ以来、OWASPはbcryptより優先すべき選択肢として推奨しています。
並列度パラメータはハッシュ処理を高速化するだけですか?
いいえ、同じパラメータはマルチコアハードウェアを持つ攻撃者による総当たり攻撃も同様に高速化するため、並列度は必要以上に増やすのではなく、実際のサーバーのコア数に合わせて設定すべきです。