AES-256-GCM/CBC Encrypt & Decrypt Online | OpenSSL Compatible
Encryption How It Works
What Is AES Encryption?
AES (Advanced Encryption Standard) is the world's most widely deployed symmetric encryption algorithm, standardized by NIST in 2001. It protects everything from HTTPS connections and messaging apps to disk encryption and secure backups. AES operates on 128-bit blocks using a series of transformation rounds (10/12/14 rounds for AES-128/192/256), applying four key operations: SubBytes (non-linear byte substitution), ShiftRows (row transposition), MixColumns (finite field multiplication), and AddRoundKey (XOR with round key). This design provides both confusion (complex relationship between key and ciphertext) and diffusion (each plaintext bit affects many ciphertext bits), making AES resistant to all known practical attacks.
AES-256, with its 2256 possible keys, offers a security margin that no foreseeable computing technology can brute-force — even quantum computers with Grover's algorithm would require 2128 operations, still computationally infeasible. It has been adopted by the U.S. government for Top Secret information, by TLS 1.3 for web traffic, and by countless open-source libraries.
Mode Selection Guide
| Mode | Type | Authenticated | Padding | Best For | Performance |
|---|---|---|---|---|---|
| Standard (GCM) | Block + counter | Yes (GMAC tag) | No (streaming) | General-purpose, API payloads, TLS 1.3 | ~10 GB/s (AES-NI) |
| CTR | Stream cipher | No | No | Large files, real-time streams, random access | ~10 GB/s (AES-NI) |
| OpenSSL Compatible | CBC | No | PKCS7 | Interoperability with legacy tools | ~5 GB/s (AES-NI) |
| ECB | Block cipher | No | PKCS7 | Never use — deterministic, leaks patterns | ~5 GB/s (AES-NI) |
Which mode should you use? For 95% of use cases, choose AES-GCM — it provides authenticated encryption that detects tampering automatically. Use CTR only for very large data streams where padding overhead matters. Use OpenSSL Compatible mode only when you need to exchange encrypted data with legacy tools that expect the "Salted__" format. Never use ECB — it encrypts identical plaintext blocks to identical ciphertext blocks, leaking data patterns (the famous "ECB penguin" problem).
AES-128 vs AES-192 vs AES-256
| Variant | Key Size | Rounds | Security Level | Performance | Use Case |
|---|---|---|---|---|---|
| AES-128 | 128 bits (16 bytes) | 10 | Sufficient for most applications | Fastest (baseline) | General web traffic, non-sensitive data |
| AES-192 | 192 bits (24 bytes) | 12 | Marginal benefit over 128 | ~10% slower | Rarely used in practice |
| AES-256 | 256 bits (32 bytes) | 14 | Highest; future-proof vs Grover's | ~20% slower | Compliance (HIPAA, PCI-DSS, FIPS 140-3), disk encryption, classified data |
Recommendation: Use AES-256 for all new projects — the 20% performance penalty is negligible on modern hardware with AES-NI acceleration, and you get the highest security margin. AES-128 remains perfectly secure for most applications, but AES-256 future-proofs against potential cryptanalytic breakthroughs.
Standards Compliance
- Web Crypto API — W3C Recommendation (2017), supported by all modern browsers
- NIST FIPS 197 — The official AES specification (2001)
- NIST SP 800-38D — GCM mode specification (2012)
- TLS 1.3 — RFC 8446 (2018), mandates AES-GCM as the preferred cipher suite
- OpenSSL — Compatible with OpenSSL 1.1.1+ and LibreSSL 3.0+
Last updated:
Code Examples
Encrypt and decrypt with AES-256-GCM across multiple languages and platforms:
Browser — Web Crypto API (Hardware-Accelerated)
// AES-256-GCM encrypt with random IV and salt
const enc = new TextEncoder();
const key = await crypto.subtle.generateKey(
{ name: 'AES-GCM', length: 256 }, true, ['encrypt', 'decrypt']
);
const iv = crypto.getRandomValues(new Uint8Array(12));
const ciphertext = await crypto.subtle.encrypt(
{ name: 'AES-GCM', iv }, key, enc.encode('secret message')
);
// Export key for storage (JWK format)
const exported = await crypto.subtle.exportKey('jwk', key);
console.log('Key:', exported.k);
console.log('IV:', Array.from(iv).map(b => b.toString(16).padStart(2, '0')).join('')); Python — PyCryptodome / cryptography
# AES-256-GCM with authenticated encryption
from Crypto.Cipher import AES
import os
key = os.urandom(32) # 256-bit key
iv = os.urandom(12) # 96-bit IV for GCM
cipher = AES.new(key, AES.MODE_GCM, nonce=iv)
ciphertext, tag = cipher.encrypt_and_digest(b'secret message')
print(f'Key: {key.hex()}')
print(f'IV: {iv.hex()}')
print(f'Ciphertext: {ciphertext.hex()}')
print(f'Tag: {tag.hex()}') Go — crypto/aes + crypto/cipher
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
)
func main() {
key := make([]byte, 32) // AES-256
rand.Read(key)
block, _ := aes.NewCipher(key)
gcm, _ := cipher.NewGCM(block)
nonce := make([]byte, gcm.NonceSize())
rand.Read(nonce)
ciphertext := gcm.Seal(nonce, nonce, []byte("secret message"), nil)
fmt.Printf("Ciphertext: %x\n", ciphertext)
} Rust — aes-gcm crate
use aes_gcm::{Aes256Gcm, Key, Nonce};
use aes_gcm::aead::{Aead, KeyInit, OsRng};
use rand::RngCore;
let key = Key::<Aes256Gcm>::generate(&mut OsRng);
let mut nonce_bytes = [0u8; 12];
OsRng.fill_bytes(&mut nonce_bytes);
let nonce = Nonce::from_slice(&nonce_bytes);
let cipher = Aes256Gcm::new(&key);
let ciphertext = cipher.encrypt(nonce, b"secret message".as_ref()).unwrap();
println!("Key: {:?}", key.as_slice());
println!("Nonce: {:?}", nonce_bytes);
println!("Ciphertext: {:?}", ciphertext); Node.js — crypto module
const crypto = require('crypto');
const key = crypto.randomBytes(32); // AES-256
const iv = crypto.randomBytes(12); // 96-bit IV for GCM
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
const encrypted = Buffer.concat([cipher.update('secret message'), cipher.final()]);
const tag = cipher.getAuthTag();
console.log('Key:', key.toString('hex'));
console.log('IV:', iv.toString('hex'));
console.log('Ciphertext:', encrypted.toString('hex'));
console.log('Tag:', tag.toString('hex')); Common Pitfalls & Attack Vectors
Security Notes
Disclaimer
Disclaimer: This page is for educational and testing purposes only. It does not constitute professional security advice. For production use of cryptographic primitives (keys, certificates, JWT, TLS), consult official standards (NIST, IETF) and conduct a formal security review.
Further Reading & Standards
- NIST FIPS 197 — The official AES specification: Advanced Encryption Standard (AES)
- NIST SP 800-38A — Recommendations for block cipher modes of operation: Block Cipher Modes
- NIST SP 800-38D — GCM mode specification: Galois/Counter Mode (GCM)
- RFC 4106 — AES-GCM for IPsec: The Use of Galois/Counter Mode in IPsec ESP
- RFC 8439 — ChaCha20 and Poly1305 comparison: ChaCha20 and Poly1305 for IETF Protocols
- OWASP Cryptographic Guidelines — Cryptographic Storage Cheat Sheet
- Deep Dive Blog — Read our comprehensive guide: AES-256 Encryption: The Complete Guide (history, modes, performance benchmarks, key management)
Related Concepts
- Symmetric Encryption — How shared-key cryptography works and why it's faster than asymmetric encryption
- Block Cipher Modes — ECB, CBC, CTR, GCM explained with security trade-offs
- Key Management — Generation, storage, rotation, and destruction best practices
- Post-Quantum Cryptography — How quantum computers will affect AES and what to prepare for
Related Tools
Need a strong passphrase for your encryption key? The Passphrase Generator creates memorable, high-entropy passphrases. For key derivation with configurable parameters, the KDF Hash Generator supports PBKDF2, Argon2id, and Scrypt. For ChaCha20 (a modern alternative to AES), try the ChaCha20 Encrypt/Decrypt tool.
Frequently Asked Questions
What is the difference between Passphrase and Raw Key mode?
Passphrase mode derives an encryption key from your passphrase using PBKDF2 (100,000 iterations), making it easy to use — you only need to remember a password. Raw Key mode lets you provide the exact key bytes (in hex or text), giving you full control over the encryption key. Raw Key mode is useful for interoperability with other systems that use specific keys.
Should I use GCM, CTR, or OpenSSL Compatible mode?
Use Standard (AES-GCM) for most cases — it provides authenticated encryption that detects tampering. Use CTR for large data streams where padding overhead matters. Use OpenSSL Compatible only when you need to exchange encrypted data with tools that expect the OpenSSL "Salted__" format.
What key length should I choose?
AES-256 is recommended for all use cases — the performance difference vs AES-128 is negligible on modern hardware. AES-128 is still secure and slightly faster. AES-192 is rarely used in practice. All three are NIST-approved.
Can I use a custom Initialization Vector (IV)?
Yes. When using the Standard encryption method, open Advanced Options and switch the IV to "Custom IV". Enter a 24-character hex string (96 bits) to use a specific IV instead of a randomly generated one. This is useful for interoperability with other systems that require a fixed IV. The custom IV is embedded in the ciphertext output and automatically extracted during decryption.
Can I decrypt ciphertext from other tools?
Yes! This tool automatically detects and decrypts OpenSSL-format ciphertext (starting with "Salted__" prefix, commonly used by other online tools). For Standard format, use this tool for both encryption and decryption. If you need to share encrypted data with other tools, select "OpenSSL Compatible" format when encrypting.
Why does the same text produce different ciphertext each time?
A fresh random salt and IV are generated for every encryption operation. This is correct and intended — it ensures identical plaintext never produces identical ciphertext. Decryption still works because both the salt and IV are embedded in the output.
Privacy: This tool runs entirely in your browser — nothing is uploaded or stored. · Disclaimer: For educational purposes only. Not professional security advice.
More in Encryption
ChaCha20 / Salsa20 Encrypt/Decrypt
Encrypt and decrypt with ChaCha20, XChaCha20, ChaCha20-Poly1305 (AEAD), or Salsa20 online. Passphrase mode with PBKDF2 key derivation.
RSA Encrypt / Decrypt
Encrypt and decrypt with RSA-OAEP online via Web Crypto API. Built-in key generator, PKCS#8/PKCS#1 conversion, SHA-256/384/512.
DES Encrypt/Decrypt
Encrypt and decrypt with DES or 3DES (Triple DES) online. CBC/ECB/CFB/OFB modes, PKCS7/NoPadding, OpenSSL compatible.
XOR Encrypt/Decrypt
Encrypt and decrypt with XOR cipher online. Text/Hex/Base64 formats, visual XOR table, brute-force key breaking, auto-solve.
JWE Encrypt / Decrypt
Encrypt and decrypt JWE (JSON Web Encryption) tokens online. RSA-OAEP, AES key wrap, PBES2 password-based key management, A128GCM/A256GCM.
Blowfish Encrypt/Decrypt
Encrypt and decrypt with Blowfish online. 5 cipher modes, 5 paddings, GBK/UTF-16 support, OpenSSL passphrase compatible.
PGP Encrypt / Decrypt
Encrypt, decrypt, sign, and verify with OpenPGP online. Public key and password modes, built-in key generator, GnuPG compatible.