แฮช/การเข้ารหัส
Scrypt Hash + Verify
แฮชรหัสผ่านด้วย scrypt (RFC 7914, memory-hard 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: เหตุใดอัลกอริทึมนี้จึงต้องการหน่วยความจำมากขนาดนั้น
คำถามที่พบบ่อย
scrypt ต่างจาก bcrypt หรือ PBKDF2 อย่างไร?
Scrypt ถูกออกแบบให้ต้องใช้หน่วยความจำมากและใช้ CPU หนักโดยตั้งใจ ทำให้เจาะด้วย GPU หรือฮาร์ดแวร์ ASIC เฉพาะทางมีต้นทุนสูงกว่า bcrypt หรือ PBKDF2 มาก ซึ่งต้านทานได้หลัก ๆ แค่บรูทฟอร์สที่ใช้ CPU
พารามิเตอร์ N, r และ p ควบคุมอะไร?
N กำหนดต้นทุน CPU/หน่วยความจำ (ต้องเป็นเลขยกกำลังสอง) r กำหนดขนาดบล็อกที่ส่งผลต่อการใช้หน่วยความจำต่อการทำงาน และ p กำหนดความขนาน การเพิ่มค่าใดค่าหนึ่งจะเพิ่มต้นทุนทรัพยากรทั้งสำหรับการใช้งานที่ถูกต้องและการโจมตี
scrypt ยังเป็นตัวเลือกที่ดีเมื่อเทียบกับ Argon2 หรือไม่?
Scrypt ยังคงมั่นคงและผ่านการพิสูจน์มาแล้ว แต่ระบบใหม่มักแนะนำ Argon2 (ผู้ชนะ Password Hashing Competition) เพราะให้การควบคุมหน่วยความจำและความทนทานต่อ side-channel ที่ละเอียดกว่า
scrypt ใช้หน่วยความจำจริงเท่าใด?
ประมาณ 128 × N × r ไบต์ต่อการคำนวณหนึ่งครั้ง ที่พารามิเตอร์ทั่วไป (N=16384, r=8) จะอยู่ที่ประมาณ 16 เมกะไบต์ต่อแฮชหนึ่งครั้ง — ไม่มากสำหรับการล็อกอินครั้งเดียว แต่มีนัยสำคัญเมื่อมีการยืนยันตัวตนพร้อมกันหลายพันครั้งบนเซิร์ฟเวอร์
scrypt ถูกนำไปใช้ที่ไหนอีกนอกจากการแฮชรหัสผ่าน?
scrypt เป็นที่รู้จักในฐานะอัลกอริทึม proof-of-work ในคริปโทเคอร์เรนซีบางชนิด (เช่น Litecoin) — ถูกเลือกใช้เพราะทนทานต่อการขุดด้วยอุปกรณ์ ASIC เฉพาะทาง ซึ่งเป็นลักษณะเด่นของบิตคอยน์ที่ใช้ SHA-256