AES key generator
A random 128-, 192- or 256-bit key for AES, ChaCha20, Twofish or HMAC, created with your browser's cryptographic random generator.
32 bytes · 64 characters
Paste it into your project
The same key as above, already where it goes.
A line for your .env file. Change the variable name to the one your program reads.
Or generate it on your machine
If you would rather not trust any website, these commands give a key that is just as good.
openssl rand -hex 32node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"python3 -c "import secrets; print(secrets.token_hex(32))"Looking for a password? Password generator
Frequently asked questions
Is it safe to generate the key here?
Yes. The key is created in your browser with crypto.getRandomValues and is not sent to the server or stored anywhere. You can check it: with the page open, go offline and it keeps generating keys. If you would still rather not depend on a website, use one of the commands above.
128, 192 or 256 bits?
All three are secure and NIST approves all three. 256 is the usual choice for data that must stay protected for many years, because it leaves margin against a future quantum computer. 192 is rarely used.
Hexadecimal or Base64?
They are the same key written in two ways: use the one your library or configuration asks for. Base64 URL changes two characters and drops the padding, so the key can go in a URL or a JWT.
Can I use it on Cifrar Online?
Yes, as a password: paste the hexadecimal version into the tool. Cifrar Online derives another key from it with Argon2id, so what you encrypt there cannot be decrypted in OpenSSL with this key.
What is the IV, and can I reuse it?
The IV (or nonce) makes encrypting the same data twice give different results. It is not secret and is stored alongside the ciphertext, but it must never be repeated with the same key: generate a new one for each encryption. GCM uses 12 bytes and CBC 16.
How many characters does an AES-256 key have?
It is 32 bytes: 64 characters in hexadecimal or 44 in Base64. A 128-bit key is 16 bytes (32 and 24 characters) and a 192-bit one, 24 bytes (48 and 32).
How should I store the key?
Outside the code and the repository: in an environment variable or a secrets manager. If it leaks, whoever has it can decrypt everything encrypted with it.
Can I use it with algorithms other than AES?
Yes. It is a sequence of random bytes, so it works for any symmetric cipher that takes a key of the same size, such as ChaCha20-Poly1305 or Twofish with 256 bits, and as an HMAC secret or to sign a JWT with HS256. Use a different key for each purpose. It does not work for RSA or elliptic curves: their keys have a mathematical structure and are generated with their own tools.
What is the key drawing?
Each byte is a point on a circle of 256 positions, joined by a line to the next one. Two different keys give different drawings: it lets you recognise at a glance that you are still looking at the same key.