Make Tools
2026-04-11

AES Encryption Online: Protect Your Data in the Browser

Learn how AES encryption works, explore CBC and GCM modes, and encrypt text or files directly in your browser — no data leaves your device.

EncryptionSecurityPrivacy

Why Browser-Based Encryption?

Encryption transforms readable data into ciphertext that only someone with the correct key can decrypt. AES (Advanced Encryption Standard) is the most widely used symmetric encryption algorithm — adopted by governments, banks, and tech companies worldwide.

Browser-based encryption has a key advantage: your data never leaves your device. There's no server to trust, no data to leak, and no account required. Our AES Encryption Tool performs all operations client-side using the Web Crypto API.

How AES Works

AES operates on 128-bit blocks of data using keys of 128, 192, or 256 bits. The algorithm processes data through multiple rounds of substitution, permutation, and mixing:

  • AES-128: 10 rounds — sufficient for most applications
  • AES-192: 12 rounds — rarely used in practice
  • AES-256: 14 rounds — maximum security, required for top-secret data
Plaintext → [AES Encrypt + Key] → Ciphertext
Ciphertext → [AES Decrypt + Key] → Plaintext

Modes of Operation

CBC (Cipher Block Chaining)

Each block is XORed with the previous ciphertext block before encryption. Requires an initialization vector (IV). Vulnerable to padding oracle attacks if implemented incorrectly.

// AES-CBC encryption with Web Crypto API
async function encryptAES(plaintext, password) {
  const enc = new TextEncoder();
  const keyMaterial = await crypto.subtle.importKey(
    'raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']
  );
  const salt = crypto.getRandomValues(new Uint8Array(16));
  const iv = crypto.getRandomValues(new Uint8Array(16));
  const key = await crypto.subtle.deriveKey(
    { name: 'PBKDF2', salt, iterations: 100000, hash: 'SHA-256' },
    keyMaterial, { name: 'AES-CBC', length: 256 }, false, ['encrypt']
  );
  const ciphertext = await crypto.subtle.encrypt(
    { name: 'AES-CBC', iv }, key, enc.encode(plaintext)
  );
  return { ciphertext, iv, salt };
}

GCM (Galois/Counter Mode)

GCM provides both encryption and authentication in a single operation. It's the recommended mode for modern applications — faster than CBC and resistant to tampering.

// AES-GCM encryption (recommended)
async function encryptGCM(plaintext, password) {
  const enc = new TextEncoder();
  const salt = crypto.getRandomValues(new Uint8Array(16));
  const iv = crypto.getRandomValues(new Uint8Array(12)); // 12 bytes for GCM
  const keyMaterial = await crypto.subtle.importKey(
    'raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']
  );
  const key = await crypto.subtle.deriveKey(
    { name: 'PBKDF2', salt, iterations: 100000, hash: 'SHA-256' },
    keyMaterial, { name: 'AES-GCM', length: 256 }, false, ['encrypt']
  );
  const ciphertext = await crypto.subtle.encrypt(
    { name: 'AES-GCM', iv }, key, enc.encode(plaintext)
  );
  return { ciphertext, iv, salt };
}

Key Derivation: From Password to Key

AES requires a fixed-length key, but human passwords are variable-length and low-entropy. Key derivation functions (KDFs) solve this by stretching passwords into strong keys:

  • PBKDF2: The standard — applies a hash function repeatedly (100,000+ iterations).
  • Argon2: Memory-hard, resistant to GPU attacks — the modern choice.
  • scrypt: Memory-hard alternative to PBKDF2.
# Python: Derive a key from password
from hashlib import pbkdf2_hmac
import os

password = b"my-secret-password"
salt = os.urandom(16)
key = pbkdf2_hmac('sha256', password, salt, iterations=100000, dklen=32)
print(f"Derived key: {key.hex()}")

Encrypting Files in the Browser

With the File API and Web Crypto, you can encrypt files entirely client-side:

  1. User selects a file via <input type="file">
  2. File contents are read as an ArrayBuffer
  3. AES-GCM encrypts the buffer with a password-derived key
  4. Encrypted blob is offered as a download

Our Encryption Tool handles this workflow for both text and file inputs, producing encrypted output that can only be decrypted with the correct password.

Common Encryption Mistakes

  • Reusing IVs: Never reuse an IV with the same key — it completely breaks security in GCM mode.
  • Weak passwords: AES-256 with a 4-character password provides zero real security.
  • Not authenticating: Use authenticated modes (GCM) or add HMAC. Encryption without authentication is vulnerable to tampering.
  • Rolling your own crypto: Use established libraries and APIs. Custom implementations almost always have bugs.

AES vs Other Algorithms

  • ChaCha20-Poly1305: Modern alternative to AES-GCM, faster on devices without AES hardware acceleration.
  • RSA: Asymmetric (different keys for encrypt/decrypt). Use RSA to exchange AES keys, then AES for the actual data.
  • 3DES: Legacy algorithm, deprecated — use AES instead.

FAQ

Is AES-256 more secure than AES-128?

Technically yes, but AES-128 is already computationally infeasible to brute-force. AES-256 provides a margin against theoretical quantum attacks. For most use cases, both are safe.

Can I encrypt text and share it with someone?

Yes. Encrypt your message with a shared password, send them the ciphertext, and they decrypt it with the same password. Just share the password through a separate channel (not the same one you send the ciphertext through).

Is browser encryption really secure?

Yes, when using the Web Crypto API. It leverages the operating system's cryptographic libraries and provides the same algorithms used in server-side implementations. The advantage: no data ever leaves your device.

What happens if I forget my password?

There's no recovery. AES encryption is designed to be unbreakable without the key. Store passwords in a password manager to avoid losing access to your encrypted data.

Conclusion

AES encryption protects your data from unauthorized access — whether it's stored on disk, transmitted over the network, or shared with collaborators. Our AES Encryption Tool brings military-grade encryption to your browser with a simple interface: enter text, set a password, encrypt. No data leaves your device.

Ready to try it?

Open Tool →