Random Bytes Generator

Generate cryptographically secure random bytes for keys, salts, nonces and tests — in the format your code needs.

● 🔒 Your data is processed locally in your browser with the Web Crypto API and is never uploaded to our servers.

How to generate random bytes

  1. Choose the number of bytes (1 to 4,096). 32 is the default.
  2. Choose the format: hex, Base64, Base64URL, C array, JavaScript Uint8Array, Python bytes, Go []byte or binary.
  3. Click Generate, then copy the result — or download a .bin file with the raw bytes.

How many bytes do I need?

UseBytesBits
AES-GCM IV / nonce1296
Salt for password hashing16128
Unique ID, session token16–32128–256
AES-256 key, HMAC-SHA256 key32256
HMAC-SHA512 key64512

128 bits can't be guessed by brute force; 256 bits leaves a wide margin for long-lived keys.

Length of each format

The same 32 bytes take 64 characters in hex, 44 in Base64 (with = padding) and 43 in Base64URL (without padding, safe in URLs and file names). Hex is easy to read and compare; Base64 is about a third shorter.

Why “cryptographically secure” matters

Bytes come from crypto.getRandomValues(), which uses your operating system's secure random number generator. Ordinary functions like Math.random() are predictable: an attacker who sees a few outputs can guess the next ones. Never use them for keys, tokens or salts.

Generate random bytes in code

WhereCode
Command lineopenssl rand -hex 32
Pythonsecrets.token_bytes(32) or secrets.token_hex(32)
Node.jscrypto.randomBytes(32)
Browser JavaScriptcrypto.getRandomValues(new Uint8Array(32))
Gocrypto/rand.Read(b)

FAQ

Are the bytes sent or stored anywhere?

No. They're generated in your browser with the Web Crypto API and never uploaded.

I need a key for a framework config. Which tool?

The Secret Key Generator makes ready-to-paste secrets (prefixed keys, JWT HS256, alphanumeric…). For AES keys, see the AES Key Generator.

And salts or IVs?

Use the Salt Generator or the IV Generator.