AES Key Generator
Generate cryptographically random AES encryption keys in your browser — keys never leave your device.
About AES Key Generation
AES (Advanced Encryption Standard) is the most widely used symmetric cipher, standardized by NIST in 2001. It supports key sizes of 128, 192, and 256 bits; 256-bit is recommended for long-term confidentiality. This tool uses crypto.subtle.generateKeyto produce a cryptographically random key via the browser's CSPRNG, then exports the raw bytes for display. The mode selector is informational — AES-GCM is the preferred authenticated encryption mode, AES-CBC requires a separate MAC, and AES-CTR turns AES into a stream cipher. All three use the same key size. Keys are never sent to any server; all computation runs locally in your browser.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Producing a key for a service that expects raw key material rather than a password.
- Generating a key of an exact size for a cipher implementation that will reject anything else.
- Producing the same key in more than one encoding to configure two systems that disagree on format.
- Creating a throwaway key for a test that must not use a production one.
- Rotating a key on a schedule where the old and new must coexist briefly.
Frequently Asked Questions
- Where does the randomness come from?
- crypto.subtle.generateKey, backed by the platform CSPRNG — the same source as crypto.getRandomValues, seeded by the operating system. Not Math.random, which is fast, predictable from a handful of outputs, and unsuitable for anything that has to stay secret.
- Which key size should I choose?
- 128-bit remains secure and is what TLS usually negotiates; 256-bit is the normal choice for data that must stay confidential for decades. The round counts differ too — 10 for AES-128, 12 for AES-192, 14 for AES-256. AES-192 is legal but rare enough that some libraries and hardware paths skip it.
- Why does the same key look different lengths?
- Same bytes, different notation. A 256-bit key is 32 bytes: 64 hex characters, 44 base64 characters including one = of padding, or 43 in base64url with padding dropped. AES-192 is the only size whose byte count divides evenly by three, so its base64 form needs no padding at all.
- Does switching the output format change the key?
- No — the key material is the state and the encoding is a view of it. That separation is load-bearing: when the formatted string was the state, changing format regenerated the key, so anyone who copied the hex and then flipped to base64 to check it walked away with two unrelated keys.
- Can I use this as a password?
- No, in both directions. This is raw key material for a cipher, not something a person types; and wherever a passphrase is expected you need a KDF — PBKDF2, scrypt or Argon2 — because a password carries far less entropy than 256 random bits. Changing key size mints a new key, since 128 bits cannot be reread as 256.
Common errors and gotchas
- Using a generated key as a password. It is raw bytes, and putting it through a key derivation function again is not what a cipher expects.
- Reading the encoding change as a different key. Hex and Base64 are two views of identical bytes.
- Choosing 256 bits and assuming the system is now secure, when the weak point is usually key handling rather than key size.
- Storing the key next to the ciphertext, which removes the only thing the encryption depended on.
- Generating a key of the wrong length for the algorithm and getting an opaque error rather than a clear one.