Mã hóa và giải mã AES
Please read before use
• This tool runs entirely in your browser. No plaintext, ciphertext, or key is sent to a server.
• It is intended for development, debugging, learning and self-managed scenarios. Do not use this page as the only protection for production secrets, customer data, or anything that requires auditing.
• For real applications: use audited libraries (libsodium, OpenSSL, AWS Encryption SDK), a real KDF (Argon2id ≥ 1 iteration / 64 MiB), AEAD modes only, and manage keys on the server with proper access control.
Văn bản UTF-8
Mode comparison — GCM vs CBC vs CTR▼
| Mode | Authentication | IV requirement | Performance | Recommended use |
|---|---|---|---|---|
| AES-GCM | Yes (AEAD, 128-bit tag) | 12 bytes (recommended); never reuse with same key | Fast, hardware-accelerated | Default — modern API, file encryption, anything authenticated |
| AES-CBC | No — must add HMAC/MAC | 16 bytes; unpredictable (CSPRNG) and never reuse | Fast, hardware-accelerated | Legacy TLS, disk encryption (XTS-AES), never use raw for new designs |
| AES-CTR | No — must add HMAC/MAC | 16 bytes; never reuse with same key (catastrophic if reused) | Fastest, parallelizable | Random-access streams, disk encryption, but combine with MAC |
Reading the table
- • AES-GCM is the only AEAD among the three — it both encrypts and authenticates in one step. If you don't know which to choose, choose GCM.
- • CBC and CTR only provide confidentiality. They need a separate MAC (HMAC-SHA256, compute-then-MAC) or they are vulnerable to chosen-ciphertext and bit-flipping attacks.
- • Both IV and nonce must be unique per (key, message). GCM with a reused IV leaks the authentication key — treat as catastrophic.
Ghi chú về chế độ và định dạng
- • SubtleCrypto của trình duyệt chỉ cung cấp GCM, CBC và CTR cho AES — không có ECB, CFB hay OFB (để tránh cách dùng yếu). Nếu cần chế độ khác, hãy dùng OpenSSL hoặc thư viện phía máy chủ.
- • Định dạng bản mã tùy chọn: Hex / Base64 / Base64URL, tương thích với CyberChef, API, JWT, v.v. Cả hai phía (mã hóa và giải mã) phải chọn cùng một định dạng.
- • Trong AES-GCM, đầu ra là luồng byte liên tục «bản mã + thẻ xác thực»; công cụ mã hóa toàn bộ khối theo định dạng đã chọn — dán toàn bộ khối khi giải mã.
Ghi chú
- • Web Crypto chạy hoàn toàn trong trình duyệt; GCM là mã hóa xác thực, phù hợp cho các tình huống mặc định.
- • Khi mã hóa, để IV trống: công cụ sẽ sinh IV ngẫu nhiên và điền vào ô trên để tái sử dụng khi giải mã.
- • Khi giải mã, để IV trống sẽ thử vector toàn 0 (chỉ hợp lệ khi phía kia dùng cùng quy ước).
Công cụ online miễn phí để mã hóa và giải mã AES với AES-CBC, AES-GCM và AES-CTR. Hỗ trợ khóa AES-128/192/256, định dạng ciphertext Hex/Base64/Base64URL, dẫn xuất khóa từ mật khẩu bằng PBKDF2-SHA256, tạo IV/salt ngẫu nhiên và xử lý Web Crypto hoàn toàn trong trình duyệt.