Hash/Mật mã
Argon2 Hash + Verify
Băm mật khẩu bằng Argon2 (người chiến thắng Password Hashing Competition, RFC 9106) — các biến thể d/i/id, với xác minh so với mã băm đã có.
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.
Bài viết về công cụ này: Argon2: vì sao thuật toán này giành chiến thắng cuộc thi băm mật khẩu
Câu hỏi thường gặp
Vì sao Argon2 được khuyến nghị hơn các hàm băm cũ như MD5 hay SHA-256 cho mật khẩu?
Argon2 được thiết kế cố ý chậm và tốn nhiều bộ nhớ, khiến việc brute-force và bẻ khóa bằng GPU/ASIC đắt đỏ hơn nhiều — khác với các hàm băm đa dụng nhanh như MD5 hay SHA-256, vốn không phù hợp để lưu mật khẩu.
Các tham số bộ nhớ, số lần lặp và độ song song kiểm soát điều gì?
Chi phí bộ nhớ quy định mỗi lần thử băm cần bao nhiêu RAM, số lần lặp kiểm soát số vòng chạy, và độ song song quy định số luồng — tăng bất kỳ tham số nào cũng làm tăng chi phí bẻ khóa nhưng khiến việc băm chậm hơn.
Tôi nên dùng biến thể Argon2 nào — d, i, hay id?
Argon2id là lựa chọn mặc định được khuyến nghị để băm mật khẩu, vì nó kết hợp khả năng chống tấn công kênh bên của Argon2i với khả năng chống bẻ khóa bằng GPU của Argon2d.
Argon2 trở thành tiêu chuẩn từ đâu?
Argon2 đã chiến thắng Password Hashing Competition năm 2015 — một cuộc thi mở dành cho các nhà mật mã học, nhằm tìm ra thuật toán tốt nhất để băm mật khẩu. Từ đó OWASP khuyến nghị nó là lựa chọn ưu tiên hơn bcrypt.
Tham số song song hóa chỉ giúp tăng tốc băm thôi sao?
Không, chính tham số đó cũng tăng tốc quá trình dò tìm cho kẻ tấn công sở hữu phần cứng nhiều lõi, vì vậy mức độ song song hóa nên được chọn phù hợp với số lõi thực tế của máy chủ, chứ không nên tăng lên mà không cần thiết.