แฮช/การเข้ารหัส
AES Encrypt/Decrypt
เข้ารหัสและถอดรหัสข้อความด้วย AES-GCM หรือ AES-CBC โดยใช้รหัสผ่าน (คีย์ได้มาจาก PBKDF2)
AES is the standard for symmetric encryption: the same password is used to both encrypt and decrypt. This tool derives an encryption key from your password with PBKDF2 and encrypts text with AES-GCM or AES-CBC — all locally in your browser.
How to use it
- Encrypt: enter text and a password, pick a mode (GCM or CBC), and get an encrypted result along with the parameters (salt, IV) needed to decrypt it later.
- Decrypt: paste the encrypted text and the same password to get the original back.
- AES-GCM is the recommended default: it encrypts and verifies data integrity at the same time (authenticated encryption).
Common uses
- Encrypting sensitive text before storing it or sending it over an untrusted channel.
- Checking that an AES encryption implementation matches across different languages or libraries.
- A teaching example for understanding the difference between the GCM and CBC encryption modes.
Things to keep in mind
The IV (initialization vector) must be unique for every encryption performed with the same key — reusing a key+IV pair in GCM completely breaks the encryption's security.
AES-CBC without a separate integrity check (a MAC) is vulnerable to ciphertext-tampering attacks — that's why GCM, which combines encryption and authentication in one mode, is the safer default.
บทความเกี่ยวกับเครื่องมือนี้: AES: การเข้ารหัสแบบสมมาตรทำงานอย่างไร
คำถามที่พบบ่อย
AES ในเครื่องมือนี้รองรับขนาดคีย์แบบใดบ้าง และควรใช้แบบไหน?
AES รองรับคีย์ขนาด 128, 192 และ 256 บิต โดยทั่วไปแนะนำ AES-256 สำหรับแอปพลิเคชันใหม่ เพราะ 128 บิตถือว่าปลอดภัยอยู่แล้ว แต่ 256 บิตให้ระยะปลอดภัยเพิ่มเติมโดยแทบไม่มีต้นทุนในทางปฏิบัติ
โหมดการเข้ารหัส (เช่น CBC, GCM) ต่างกันอย่างไร?
GCM ตรวจสอบความถูกต้องของไซเฟอร์เท็กซ์ไปพร้อมกับการเข้ารหัส จึงตรวจจับการปลอมแปลงได้ด้วย ทำให้เป็นค่าเริ่มต้นที่แนะนำ ส่วน CBC เข้ารหัสอย่างเดียวและต้องใช้ MAC แยกต่างหากเพื่อความถูกต้อง รวมถึงต้องมี IV แบบสุ่มทุกครั้งที่เข้ารหัสเพื่อความปลอดภัย
คีย์หรือข้อความต้นฉบับของฉันถูกส่งไปที่ไหนหรือไม่?
ไม่ การเข้ารหัสและถอดรหัสทั้งหมดทำงานในเบราว์เซอร์ของคุณผ่าน Web Crypto API ไม่มีการอัปโหลดข้อมูลใดไปยังเซิร์ฟเวอร์
เหตุใดจึงไม่ควรใช้โหมด ECB?
ECB เข้ารหัสแต่ละบล็อกอย่างอิสระและเหมือนกัน ดังนั้นบล็อกข้อความธรรมดาที่เหมือนกันจะให้บล็อกข้อความเข้ารหัสที่เหมือนกัน — สิ่งนี้เผยให้เห็นโครงสร้างของข้อมูล (เช่น รูปแบบที่ซ้ำกันในภาพยังคงมองเห็นได้แม้จะเข้ารหัสแล้ว) CBC หรือ GCM ที่มี IV ไม่ซ้ำกันจะขจัดปัญหานี้
จะเกิดอะไรขึ้นหากใช้ IV เดียวกันซ้ำกับคีย์เดียวกัน?
สำหรับ GCM นี่คือข้อผิดพลาดร้ายแรง — การใช้คู่คีย์+IV ซ้ำจะทำลายความลับและความถูกต้องแท้จริงของการเข้ารหัสอย่างสิ้นเชิง IV ต้องไม่ซ้ำกันเสมอสำหรับการเข้ารหัสแต่ละครั้งด้วยคีย์เดียวกัน