Skip to content

Encryption key generator

Free, no sign-up Runs in your browser

Generate random AES-128, AES-192 and AES-256 keys, GCM nonces, CBC IVs and 32-byte libsodium keys as hex and Base64, with what each size is for. Browser only.

A 256-bit AES key, for AES-256-GCM or AES-256-CBC. The usual choice for new systems, and the size to pick when the data must stay secret for many years.

Hex
The result appears here.
Base64
The result appears here.

Made in your browser with crypto.getRandomValues and not sent anywhere. Keep a key in a secret manager or an environment variable, never in the code, and never reuse one key for two purposes.

Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.

How to use the encryption key generator

  1. Choose what you need: an AES key of a given size, a nonce, an IV or a libsodium key.
  2. Read the note on what that size is for.
  3. Press Generate and copy the hex or the Base64 form, whichever your software expects.
  4. Store a key in a secret manager or an environment variable, never in the code.

About this tool

A symmetric encryption key is nothing more than random bytes of the right length. AES takes 16, 24 or 32 bytes for its 128, 192 and 256-bit versions; libsodium’s secretbox and the ChaCha20-Poly1305 family take 32. What makes a key good is where the bytes come from. This tool uses your browser’s cryptographic random generator and shows the result as hex and as Base64, the two forms config files ask for.

Besides the key, most ciphers need a per-message value: a 12-byte nonce for AES-GCM, a 16-byte IV for AES-CBC. These are not secret and travel with the ciphertext, but they have rules. A GCM nonce must never repeat under the same key, because one repeat exposes the authentication key and the difference of the two messages. A CBC IV must be unpredictable. In real code both are generated at the moment of encryption.

The common mistakes are all about what counts as a key. A password is not a key: run it through a key derivation function such as Argon2id or PBKDF2 first. A key typed by hand or made with a non-cryptographic random function is guessable. And one key should do one job. For key size, AES-128 is still secure, and AES-256 is the usual choice for new systems and for data that must stay private for decades.

Sources

Questions

How long is an AES-256 key?

Thirty-two bytes, which is 256 bits: 64 characters in hex or 44 in Base64 with padding. AES-128 keys are 16 bytes and AES-192 keys are 24. The block size of AES is 128 bits for all three, which is why a CBC IV is always 16 bytes.

Should I use AES-128 or AES-256?

Both are considered secure against known attacks. AES-256 is the common default for new designs, gives a margin against future advances including quantum search, and is required by some policies. AES-128 is a little faster. The mode, such as GCM, and correct nonce handling matter more than the key size.

What is the difference between a key, a nonce and an IV?

The key is the secret and is reused for many messages. A nonce or IV is a public value that must be different for each message, so that encrypting the same text twice does not give the same output. It is stored or sent alongside the ciphertext.

Can I use a password as an encryption key?

Not directly. A password has far less randomness than its length suggests and is the wrong size. Derive a key from it with Argon2id, scrypt or PBKDF2 with a random salt and a high work factor. If no person has to remember it, skip the password and use a random key.

Related tools