aes-128-gcm encrypt & decrypt online

Encrypt or decrypt text with aes-128-gcm and a secret. Nothing leaves your browser.

This mode needs an authentication tag.
Runs in your browser

PHP's openssl_encrypt needs a tag variable for this mode and returns no result without it. Like on the old site, the result stays empty. For working encryption use aes-256-cbc.

In short

What is aes-128-gcm?

AES is the block cipher NIST standardised in 2001 (FIPS 197), originally called Rijndael. It is the most widely used cipher today and has no practical attack. AES-128-GCM is authenticated encryption: besides the ciphertext it produces a tag that proves nobody changed it. In PHP it needs a tag variable, so this tool, like the old site, gives no result.

Strong cipherAES (Rijndael): No practical attack on the cipher itself is known.
Where you meet AES
  • HTTPS and TLS
  • Wi-Fi (WPA2, WPA3)
  • Disk encryption: BitLocker, FileVault, LUKS
  • VPNs, ZIP and 7-Zip archives, password managers
Honest answer

Is it safe to use?

The cipher: strong cipher

AES. No practical attack on the cipher itself is known.

This setup: for compatibility

The setup of this tool is made for compatibility with PHP's openssl_encrypt, not for protecting secrets: the IV is always zero, the secret is used as the key without a key derivation function, and nothing detects changes to the ciphertext.

For real secrets use an authenticated mode such as AES-256-GCM or ChaCha20-Poly1305 with a fresh random nonce for every message, and derive the key from a password with Argon2id, scrypt or PBKDF2. What is a key derivation function?

Authenticated encryption (AEAD)

How authenticated modes work

Authenticated modes (GCM, CCM, OCB, Poly1305) encrypt and at the same time compute a tag over the data. Decryption checks the tag first and fails if anything was changed. This is what you want for real encryption.

PHP's openssl_encrypt only returns a result for these modes if you pass a variable for the tag and a nonce. The old site did neither, so the result was always empty, and this tool keeps it that way.

Use it in code

AES-128-GCM done right, in your code

These snippets encrypt with a random key and nonce, keep the tag, and decrypt again. They print hello world. They are run before each release.

PHP
$key = random_bytes(16);   // store it safely
$nonce = random_bytes(12);  // new for every message
$ct = openssl_encrypt("hello world", "aes-128-gcm", $key, OPENSSL_RAW_DATA, $nonce, $tag);
$message = base64_encode($nonce . $tag . $ct); // keep nonce and tag with the ciphertext

$raw = base64_decode($message);
echo openssl_decrypt(substr($raw, 28), "aes-128-gcm", $key, OPENSSL_RAW_DATA, substr($raw, 0, 12), substr($raw, 12, 16));

The $tag argument is what the old site left out. Without it, openssl_encrypt returns false.

Python
# pip install cryptography
import os
from cryptography.hazmat.primitives.ciphers.aead import AESGCM

key = AESGCM.generate_key(bit_length=128)
nonce = os.urandom(12)  # new for every message
ct = AESGCM(key).encrypt(nonce, "hello world".encode(), None)  # tag is appended
print(AESGCM(key).decrypt(nonce, ct, None).decode())
Node.js
import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';

const key = randomBytes(16);
const nonce = randomBytes(12); // new for every message
const c = createCipheriv("aes-128-gcm", key, nonce);
const ct = Buffer.concat([c.update("hello world", 'utf8'), c.final()]);
const tag = c.getAuthTag();

const d = createDecipheriv("aes-128-gcm", key, nonce);
d.setAuthTag(tag);
console.log(Buffer.concat([d.update(ct), d.final()]).toString('utf8'));
Common mistakes

Why aes-128-gcm gives no result

Why the result is empty

Authenticated modes need a nonce and produce a tag. PHP's openssl_encrypt returns false when you don't pass a tag variable, and the old site didn't. See the code example for how to use the mode correctly.

Reusing a nonce

In GCM, the same nonce twice with the same key reveals the XOR of the two texts and lets an attacker forge tags. Use 12 random bytes per message, or a counter that never repeats.

Throwing away the tag

The 16-byte tag is part of the message. Store or send it together with the nonce and the ciphertext; decryption without it is impossible, and skipping the check gives up the protection.

Which cipher was it?

Encrypted something here years ago?

Paste the Base64 result and the secret. Your browser tries all 174 ciphers of this site and shows those that give readable text. Useful if you don't remember the cipher, or to check whether your ciphertext really is aes-128-gcm.

Nothing is sent anywhere. Wrong secrets give no readable text.
Compare

Every AES-128 variant, same input

The text The quick brown fox jumps over the lazy dog (43 bytes) with the secret my secret in all 19 AES-128 ciphers. The last column lists names that give the same result: aliases, and modes that agree for this input. Highlighted: the same start as aes-128-gcm. Watch how CBC and ECB share the first block, and CFB, OFB and CTR the first 16 bytes. Type a text and a secret in the tool above to use yours.

CipherResult (Base64)Same as
aes-128-cbc i7vfHATmvCrxYy9qiHaxyt3wvORh88GUuzSzf9bw5++CM0S6QDK4fE1yrHZ4FB16aes-128-cbc-hmac-sha1, aes-128-cbc-hmac-sha256, aes128
aes-128-cbc-hmac-sha1 i7vfHATmvCrxYy9qiHaxyt3wvORh88GUuzSzf9bw5++CM0S6QDK4fE1yrHZ4FB16aes-128-cbc, aes-128-cbc-hmac-sha256, aes128
aes-128-cbc-hmac-sha256 i7vfHATmvCrxYy9qiHaxyt3wvORh88GUuzSzf9bw5++CM0S6QDK4fE1yrHZ4FB16aes-128-cbc, aes-128-cbc-hmac-sha1, aes128
aes-128-ccm no result
aes-128-cfb SsMSzl/rFRhPJZExIDz+sUlfFDd/sM9mIwgYoe/OcKBoUd6F+Dn7koQ31w==
aes-128-cfb1 fF3w2g9a5AiBbI20o5ld5b0YUXRTx8a/xaZZESb8yORNHjq+jR5ZTOZj1Q==
aes-128-cfb8 ShS+jZYSdD3MJfBmnfEz+jKM7H9b57w11NF6NerxqRHJn7LTBwGSt6Cxjw==
aes-128-ctr SsMSzl/rFRhPJZExIDz+sfw/dZn9RqQLXEVED9wGFizt5fBWSuFBVf80sQ==
aes-128-ecb Legacyi7vfHATmvCrxYy9qiHaxytv2lacGBXo0DF+/4sBumgW7VIfdLGIsL9BqLKy3VkYU
aes-128-gcm no result
aes-128-ocb no result
aes-128-ofb SsMSzl/rFRhPJZExIDz+sQwGyExofWfDoTQanZtW4UmP030OhqzkHKJNzA==
aes-128-xts WTrZgUQlmoZxcG/d9PFwRD4r+M544ix/5U1usg5acNgHqnX6l7EW353Dxw==
aes128 i7vfHATmvCrxYy9qiHaxyt3wvORh88GUuzSzf9bw5++CM0S6QDK4fE1yrHZ4FB16aes-128-cbc, aes-128-cbc-hmac-sha1, aes-128-cbc-hmac-sha256
aes128-wrap no result
id-aes128-ccm no result
id-aes128-gcm no result
id-aes128-wrap no result
id-aes128-wrap-pad FNGT9AP/e0vOHlZxK9DxyRbU/psJmNNitheSgx9xaLyO9+uPJbw9DTr7yfX3Id+AtnjPISM2+Pw=
FAQ

Questions about aes-128-gcm

Can I decrypt AES-128-GCM here?

Not with this tool. Besides the key, GCM needs the nonce (IV) and the 16-byte authentication tag, and this tool, like PHP’s openssl_encrypt without a tag variable, has no field for them. With key, nonce, ciphertext and tag, a few lines of code decrypt it, as the code example on this page shows, for example AESGCM in Python’s cryptography package or decipher.setAuthTag() in Node.js.

Where are the nonce and the tag in my GCM data?

That depends on the program, there is no fixed layout. Python’s AESGCM, Java and the Web Crypto API in browsers append the 16-byte tag to the ciphertext, while Node.js returns it separately with getAuthTag(). Many apps put the 12-byte nonce in front, so a common layout is nonce, then ciphertext, then tag, often as Base64.

Why is the aes-128-gcm result empty?

Because PHP's openssl_encrypt returns false for authenticated modes when no tag variable is passed, and the old site passed none. The tool keeps that behaviour so old results stay comparable. Use the code example to encrypt with a nonce and tag.

Is AES-128-GCM secure?

Yes, when used correctly: AES-128-GCM with a random, never repeated nonce and the tag checked on decryption is a recommended way to encrypt data today.

Next step

Looking for something else?

Good to know

Before you rely on it

Searches the list of pages on this site. What you type stays in your browser.