Random Hex Generator (Bytes, Keys, Numbers)
Generate cryptographically random hex: n random bytes as plain hex, 0x-prefixed, C/JS byte arrays or \x escapes, or random hex numbers in a range, with Base64 view.
Random hex strings are everywhere in development: encryption keys and IVs, salts, session secrets, test data, colour seeds and unique tokens. This generator draws bytes from the browser’s cryptographically secure random source and formats them the way you need — plain hex, 0x-prefixed, spaced or colon-separated bytes, a C or JavaScript byte array, or \x escapes — and can also pick uniformly random hex numbers between two bounds of any size.
How to use this tool
- Choose random bytes or random numbers in a range.
- Set the number of bytes per value (16 for a 128-bit key, 32 for 256-bit) or the hex range.
- Pick the output format, case and how many values.
- Copy the values; the first is also shown as Base64.
Formula
entropy = bytes × 8 bits range values: uniform integer in [min, max] by rejection sampling
For a range, enough random bits to cover max − min are drawn; results outside the range are thrown away and redrawn, so every value is exactly equally likely (taking the remainder would favour small values). Big ranges use BigInt, so 256-bit bounds work.
Example
16 random bytes give a 32-digit hex string such as 3fa94c…e1, carrying 128 bits of entropy — the size of an AES-128 key. As a C array the same 4 bytes 3f a9 4c 07 become { 0x3f, 0xa9, 0x4c, 0x07 }, 26 characters long.
Frequently asked questions
Is this random enough for encryption keys?
Yes. crypto.getRandomValues is the same secure generator browsers use for TLS. For production keys, still generate them where they will be used (a key management service or your server), so they never pass through a clipboard.
How many bytes do I need?
16 bytes (128 bits) for AES-128 keys, IVs and unique IDs; 32 bytes (256 bits) for AES-256 keys and long-lived secrets; 12 bytes for an AES-GCM nonce.
Does the range mode include the maximum?
Yes, both bounds are included: 0 to ff gives 256 possible values.
Last updated:
Page address with these inputs: https://kakao.mobile/tools/random-hex-generator/
Cite or embed this tool
kakaoCalc. (2026, November 8). Random Hex Generator (Bytes, Keys, Numbers). https://kakao.mobile/tools/random-hex-generator/
“Random Hex Generator (Bytes, Keys, Numbers).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/random-hex-generator/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms