Encryption Key Generator
Generate AES key bytes in Hex, Base64, or Base64URL, with an optional GCM nonce or CBC IV.
This tool asks the browser cryptographic random source for 16, 24, or 32 bytes. Those byte lengths map to AES-128, AES-192, and AES-256. A random encryption key is machine key material, not a memorable passphrase.
A 256-bit AES key contains 32 random bytes. The same key uses 64 hexadecimal characters or 44 standard Base64 characters including padding. Choose the byte length your application expects, then copy the encoding it accepts.
| AES size | Bytes | Hex characters | Base64 characters (padded) | Base64URL characters (unpadded) |
|---|---|---|---|---|
| 128 bit | 16 | 32 | 24 | 22 |
| 192 bit | 24 | 48 | 32 | 32 |
| 256 bit | 32 | 64 | 44 | 43 |
A 32-character text password is not the same as 32 random key bytes. When an application derives a key from a password, match its PBKDF2 settings or other specified derivation method.
The three outputs represent the same bytes. Hex is longer and easy to inspect, Base64 is compact, and Base64URL replaces URL-sensitive characters and removes trailing padding. Changing the encoding does not change key strength.
- AES-GCM commonly uses a 12-byte nonce. It does not need to be secret, but it must not repeat under the same key.
- AES-CBC uses a 16-byte IV because AES has a 16-byte block size. CBC ciphertext also needs a separate integrity mechanism.
- Store the mode, encoding, nonce or IV, and other parameters with the ciphertext so the receiver can reproduce the operation.
Is Base64 a stronger key format than hex?
No. Hex and Base64 are different text encodings of the same bytes. Strength comes from the random bytes and key length.
Can I reuse the generated nonce or IV?
Generate new companion bytes for every encryption operation. Reusing a GCM nonce with the same key can break the mode's security guarantees.
How should I store generated keys?
Store long-lived keys in a key-management system. Generate new companion bytes for each encryption operation.