Skip to main content
Skip to main content
CryptographyFebruary 20, 2026 10 min read

AES-256-GCM Encryption: A Developer's Guide

Encrypt and decrypt files locally in your browser with AES-256-GCM - no upload, no account. Code examples, plus AES-256-GCM vs AES-256-CBC vs ChaCha20.

Encrypt files with our AES-256-GCM Encryptor. Your data stays in your browser.

What is AES-256-GCM?

AES-256-GCM is a way to encrypt data so only someone with the password can read it. It's used by governments, banks, and security apps worldwide.

The '256' means it uses a 256-bit key. That's a number so large it would take billions of years to guess.

The 'GCM' part adds something called 'authenticated encryption'. This means you can detect if someone tampered with the encrypted data.

How Encryption Works

Think of encryption like a lockbox. You put your data inside, lock it with a password, and only someone with that password can open it.

The magic happens through math. Your password gets stretched into a strong encryption key using a process called PBKDF2. This makes even weak passwords much stronger.

Then AES scrambles your data using that key. The result looks like random noise. Without the password, it's mathematically impossible to unscramble.

When to Use AES Encryption

  • Sensitive files - Tax documents, medical records, legal papers
  • Before cloud storage - Encrypt before uploading to Dropbox or Drive
  • Email attachments - Protect files sent over email
  • USB drives - Encrypt files on portable storage

AES-256-GCM Implementation Examples

Here is how to implement AES-256-GCM encryption in different programming languages:

Node.js (crypto module)

const crypto = require('crypto');
// Generate a random 256-bit key
const key = crypto.randomBytes(32);
const iv = crypto.randomBytes(16);
// Encrypt
const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
let encrypted = cipher.update('Secret message', 'utf8', 'hex');
encrypted += cipher.final('hex');
const authTag = cipher.getAuthTag();
console.log('Encrypted:', encrypted);
console.log('Auth Tag:', authTag.toString('hex'));

Python (cryptography library)

from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import os
# Generate a random 256-bit key
key = AESGCM.generate_key(bit_length=256)
aesgcm = AESGCM(key)
# Generate nonce (IV)
nonce = os.urandom(12)
# Encrypt
plaintext = b'Secret message'
ciphertext = aesgcm.encrypt(nonce, plaintext, None)
print(f'Key: {key.hex()}')
print(f'Nonce: {nonce.hex()}')
print(f'Ciphertext: {ciphertext.hex()}')

JavaScript (Web Crypto API)

async function encryptData(plaintext, password) {
// Derive key from password using PBKDF2
const encoder = new TextEncoder();
const passwordKey = await crypto.subtle.importKey(
'raw', encoder.encode(password), 'PBKDF2', false, ['deriveKey']
);
const salt = crypto.getRandomValues(new Uint8Array(16));
const key = await crypto.subtle.deriveKey(
{ name: 'PBKDF2', salt, iterations: 100000, hash: 'SHA-256' },
passwordKey, { name: 'AES-GCM', length: 256 }, false, ['encrypt']
);
// Encrypt
const iv = crypto.getRandomValues(new Uint8Array(12));
const encrypted = await crypto.subtle.encrypt(
{ name: 'AES-GCM', iv }, key, encoder.encode(plaintext)
);
return { encrypted, iv, salt };
}

AES-256-GCM vs AES-256-CBC vs ChaCha20

One of the most common questions developers ask is how AES-256-GCM compares to other modes before they commit to an implementation. The table below shows the differences that actually matter for client-side encryption:

For new work, AES-256-GCM is the safer default because it authenticates the ciphertext in the same operation. If you want the full walkthrough of the second option, read our AES-GCM vs ChaCha20-Poly1305 comparison.

PropertyAES-256-GCMAES-256-CBCChaCha20-Poly1305
Encryption + authenticationYes, GCM tag is built inNo, needs a separate HMAC layerYes, Poly1305 tag is built in
Hardware accelerationExcellent on x86 (AES-NI)GoodSoftware-only, very portable
Speed on mobile devicesGoodGoodOften the fastest on ARM phones
Tamper detectionImmediate, fails authenticationOnly if you add and verify HMACImmediate
Best default?Yes, for new applicationsOnly with a correct HMAC layerStrong alternative on low-power devices

How to Encrypt a File with AES-256-GCM (Step by Step)

You do not need a terminal to use AES-256-GCM. The quickest path is our browser-based AES-256-GCM Encryptor, which keeps every byte on your device. The same flow works for plain text:

Strong encryption deserves a strong password. Generate one with our password generator, and use a SHA-256 hash to verify the file did not get corrupted before you decrypt it.

  1. Open the AES-256-GCM Encryptor and switch to the text or file tab.
  2. Paste your text or drop the file you want to protect.
  3. Enter a password of at least 16 characters, or generate one.
  4. Click Encrypt. The tool derives a 256-bit key with PBKDF2 (100,000 iterations) and stores the salt, IV, and authentication tag next to the ciphertext.
  5. Download the encrypted file and keep the password somewhere separate from the file.
  6. To get your data back, open the tool again, switch to decrypt mode, and re-enter the password. If the tag does not verify, the file or the password was changed.

Password Tips

Your encryption is only as strong as your password. Here's how to make it count:

Use a passphrase - Four or five random words are easier to remember and harder to crack than random characters.

Make it long - 16 characters minimum. Longer is always better.

Don't reuse it - This password protects everything you encrypt with it. Keep it unique.

Store it safely - Use a password manager. Write it down and store it in a safe. Never lose it.

What It Can't Do

AES encryption protects your data at rest. It doesn't protect it while you're using it.

If your computer has malware, it can read the decrypted data while you work with it.

Encryption also doesn't hide that you have encrypted data. Someone can see you have a file, they just can't read it.

Frequently Asked Questions

Q.Will quantum computers break AES-256 encryption?

A.Quantum computers might eventually threaten AES-256, but not in the foreseeable future. Experts estimate breaking AES-256 would require millions of stable qubits. Current quantum computers (as of 2026) have only hundreds to thousands of qubits with high error rates. Even when quantum computers advance, doubling the key length to AES-512 (if needed) would provide protection.

Q.Does AES-256 have a government backdoor?

A.No. AES is a public standard created through an open competition and reviewed by cryptographers worldwide. The algorithm and its implementations are publicly documented and scrutinized. Independent security researchers, academics, and governments all use and trust AES. Any backdoor would have been discovered by now given the intense scrutiny.

Q.What happens if I forget my encryption password?

A.Your data remains encrypted and inaccessible forever. There is no password reset, no recovery mechanism, and no customer service that can help. This is the fundamental nature of strong encryption—the security that protects your data from attackers also prevents recovery if you lose the key. Always store passwords in a secure password manager or write them down and store in a physical safe.

Q.What does GCM mean and why does it matter?

A.GCM stands for Galois/Counter Mode. It provides both encryption (confidentiality) and authentication (integrity) in one operation. This means GCM hides your data and also detects if anyone tampered with it. Older modes like CBC only provide encryption without authentication, making them vulnerable to certain attacks. Always use authenticated encryption like GCM for new applications.

Q.How strong does my password need to be?

A.Use at least 16 characters with a mix of uppercase, lowercase, numbers, and symbols. A passphrase of 5-6 random words (like 'correct-horse-battery-staple-cloud') is even better—easier to remember and harder to crack. The password is stretched using PBKDF2 with 100,000+ iterations, but a weak password can still be guessed. Never reuse encryption passwords.

Q.Is there a limit to file size I can encrypt?

A.Browser-based encryption is limited by available memory. Files up to several hundred MB work fine. For very large files (GB+), consider using command-line tools like OpenSSL or GPG. Our tool processes files entirely in your browser—nothing is uploaded to servers—so the limitation is your device's RAM, not server constraints.

Q.Is browser-based encryption really secure?

A.Yes, when implemented correctly. Our tool uses the Web Crypto API, which is a native browser feature using the same cryptographic libraries as operating systems. The encryption happens in your browser's secure sandbox, not on our servers. You can verify this by checking the Network tab in developer tools—no data is sent during encryption.

Q.How do I share encrypted files with others?

A.Send the encrypted file through any channel (email, cloud storage, messaging). Share the password through a different, secure channel—preferably in person, encrypted message, or password manager sharing. Never send the password and file together through the same channel. The recipient can decrypt using the same tool or any AES-256-GCM compatible software.

Q.How do I decrypt AES-256-GCM data locally?

A.Use the same password, salt, and nonce that produced the ciphertext. The decryptor derives the key with the identical PBKDF2 parameters and verifies the GCM authentication tag before releasing plaintext. Because everything runs in your browser, the decrypted result is shown on your device and never sent to a server. Store the salt and nonce alongside the ciphertext—they do not need to be secret, but they must match.

References

This article is based on industry standards and best practices from authoritative sources:

  • NIST FIPS 197-upd1 - Advanced Encryption Standard (AES): https://doi.org/10.6028/NIST.FIPS.197-upd1
  • NIST SP 800-38D - Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
  • RFC 5084 - Using AES-CCM and AES-GCM Authenticated Encryption: https://www.rfc-editor.org/rfc/rfc5084
  • OWASP Cryptographic Storage Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html

Encrypt your data locally

Encrypt text or files with AES-256-GCM in your browser — no upload, no account.

Conclusion

AES-256-GCM is the default choice for authenticated client-side encryption. Encrypt or decrypt text and files locally with the AES-256-GCM Encryptor. For the decryption workflow in detail, see our AES-256-GCM decryption guide.

AES-256-GCMencryptioncryptographydata protectionsecurity