Secret Key Generator

← All tools

Create a random key with crypto.getRandomValues. Pick the length, then read it as hex, Base64, or Base64url.

The key is created in the browser. It is not uploaded, and it is not stored in the URL. The URL only keeps the length and the encoding.

Encoding

No key

These bytes are 0 through 15. They are published so the encoding can be checked. Do not use them as a secret.

Key

OpenSSL:

Node:

Changing the encoding rewrites the same bytes. Changing the length draws new bytes.

About this tool

The bytes come from crypto.getRandomValues. Lengths are 16, 24, 32, 48, and 64 bytes. 32 bytes is 256 bits. Hex is two lowercase digits per byte. Base64 is the standard alphabet, with padding. Base64url follows RFC 4648 section 5: plus becomes a hyphen, slash becomes an underscore, and the padding is stripped.

RFC 7518 section 3.2 says an HMAC key must be at least as long as the hash output. HS256 is 256 bits, which is 32 bytes. A shorter key is still random. It is just shorter than that requirement. This page does not estimate how long a key would take to guess.

openssl rand -hex N and openssl rand -base64 N are the matching commands. OpenSSL has no base64url flag. The Node one-liner uses randomBytes and toString with hex, base64, or base64url. Node's base64url is unpadded. A password generator is for a phrase a person can type. This page is for a key a program stores.

Read more

Free books, courses, and software

Get my programming books, course editions, and complete software.

Get the download library →