Encryption key generator — random AES, ChaCha20 and HMAC keys

Pick a key type and the tool fills it with random bytes from your browser's cryptographic generator, shown as hex, Base64 or Base64url, with an optional IV or nonce of the right size.

Live demo · real result from this tool
Encoding

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the encryption key generator

  1. Choose a Key type: AES-128, AES-192 or AES-256, ChaCha20 / XChaCha20, an HMAC-SHA256 or HMAC-SHA512 key, or Custom number of bytes (1 to 1,024).
  2. Pick an Encoding: Hex, Base64 or Base64url.
  3. Under Also generate, choose Key only or add a 12-byte nonce, 16-byte IV or 24-byte nonce.
  4. Set How many keys (up to 50) and press Generate. Copy the key list, and the IV or nonce list if you asked for one.

What it does and when to use it

Symmetric ciphers and message-authentication codes need a secret key of a fixed size: 16, 24 or 32 bytes for AES, 32 bytes for ChaCha20, and commonly the hash’s output length for HMAC (32 bytes for SHA-256, 64 for SHA-512). This tool gives you exactly that many random bytes in the text format your code or config expects.

Typical uses are a SECRET_KEY for signing session cookies, an AES-256 key for encrypting a backup, an HMAC key for verifying webhooks. For a password a person must type, use the strong password generator instead. To turn a password into a key, use a slow function such as the PBKDF2 generator.

How it works

Each key is a call to crypto.getRandomValues for the chosen number of bytes. Nothing is mixed in or hashed afterwards; the bytes are simply encoded. Because every bit is independently random, a key of n bytes has n × 8 bits of entropy, which is what the Key size figure reports. Guessing a 256-bit key is not a practical attack.

The IV or nonce list is drawn the same way, one per key, in the same encoding.

Worked examples

  • AES-256 in hex. Key type AES-256, Encoding Hex. The result is one 64-character hex string, plus Key size: 256 bits and Bytes: 32.
  • HMAC-SHA512 in Base64. The tool draws 64 bytes, so the stats show Bytes: 64 and a key size of 512 bits. The Base64 text is 88 characters long.
  • Asking for too much. Custom with 5,000 bytes is capped at the 1,024-byte limit, and the stats read Key size: 8192 bits.

Limits and tips

  • A key is only as safe as its storage. Never commit it to Git; rotate it if it leaks.
  • Never reuse a nonce with the same key. With AES-GCM that mistake can expose the authentication key.
  • Output is raw key material, not a key file. Tools that expect PEM, JWK or a keystore need a different format.
  • For long random tokens that are not keys, the random hex generator or the API key generator may fit better.

Frequently asked questions

Can I use these keys for real encryption?
The bytes come from crypto.getRandomValues, the browser's cryptographically secure random generator, so they are suitable as key material. What matters next is how you store them. Put the key in a secrets manager or key vault, not in source code, chat or a shared document.
What is the difference between hex, Base64 and Base64url?
They are three ways to write the same bytes as text. A 32-byte key is 64 hex characters, 44 Base64 characters (ending in =), or 43 Base64url characters. Base64url swaps + and / for - and _ and drops the padding, so it is safe inside URLs and environment variables.
Do I need the IV or nonce?
Most modes need one per message. AES-GCM and ChaCha20-Poly1305 use a 12-byte nonce, AES-CBC and AES-CTR a 16-byte IV, and XChaCha20 a 24-byte nonce. The IV is not secret, but a nonce must never repeat with the same key. In real code, generate a fresh one for every message.
Why is there no RSA or elliptic-curve option?
Those keys are not plain random bytes; they are numbers with a special mathematical structure. Use the RSA key pair generator, which asks the browser's Web Crypto API to build a proper key pair.
Is anything sent to a server?
No. The bytes are created and encoded on your device. Still, anyone who can see your screen or clipboard can copy the key, so clear it when you are done.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close