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
- Choose the number of bytes (1 to 4,096). 32 is the default.
- Choose the format: hex, Base64, Base64URL, C array, JavaScript
Uint8Array, Pythonbytes, Go[]byteor binary. - Click Generate, then copy the result — or download a .bin file with the raw bytes.
How many bytes do I need?
| Use | Bytes | Bits |
|---|---|---|
| AES-GCM IV / nonce | 12 | 96 |
| Salt for password hashing | 16 | 128 |
| Unique ID, session token | 16–32 | 128–256 |
| AES-256 key, HMAC-SHA256 key | 32 | 256 |
| HMAC-SHA512 key | 64 | 512 |
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
| Where | Code |
|---|---|
| Command line | openssl rand -hex 32 |
| Python | secrets.token_bytes(32) or secrets.token_hex(32) |
| Node.js | crypto.randomBytes(32) |
| Browser JavaScript | crypto.getRandomValues(new Uint8Array(32)) |
| Go | crypto/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.