Generate raw random bytes for keys, salts and initialisation vectors, formatted as hex, spaced hex, Base64, decimal or a C array. Byte counts map directly to bit strength: 16 bytes is 128 bits, 32 bytes is 256 bits.
Settings
Recent results
Generated locally in your browser β your settings and results never leave this page.
Bytes are where cryptographic values start
Almost every cryptographic construct begins with a block of unpredictable bytes. A key is bytes. A salt is bytes. A nonce is bytes. The algorithms that use them are public and heavily studied; the only secret is the randomness fed in at the start. That makes the quality of the byte source the foundation everything else rests on.
This tool draws from crypto.getRandomValues, the interface browsers expose to their own cryptographic random generator. It is seeded from operating-system entropy and designed so that observing past output tells an attacker nothing useful about future output. That property β not merely “looks scrambled” β is what separates a cryptographic generator from an ordinary one.
Sizes that mean something
Byte counts in cryptography are rarely arbitrary. Sixteen bytes is 128 bits, the standard AES key size and the usual floor for anything that must resist brute force. Thirty-two bytes is 256 bits, used for AES-256 and as a comfortable default for tokens. Twelve bytes is the recommended initialisation vector length for AES-GCM, chosen because that size avoids an extra internal transformation.
Where a specification names a size, that size is usually load-bearing. A salt shorter than 16 bytes weakens the protection it provides against precomputed tables. An initialisation vector of the wrong length may still work but leaves the security argument in unfamiliar territory. Generating exactly what the specification asks for is the cheapest correctness you will ever get.
Salts, nonces and the uniqueness requirement
Salts and nonces are not secrets in the way a key is β they are frequently stored alongside the data they protect, in the clear. Their job is to be different every time. A salt makes two identical passwords hash to different values, which defeats precomputed lookup tables. A nonce ensures that encrypting the same message twice does not produce the same ciphertext.
Reuse is the failure mode. Reusing a salt undoes its purpose. Reusing a nonce with the same key in a stream cipher or in GCM mode can be catastrophic, leaking relationships between messages and in some modes the ability to forge them. Generating a fresh value for each operation is not a nicety; it is the requirement.
Reading the formats
Hexadecimal is the lingua franca because every byte becomes exactly two characters, so the string length is always twice the byte count and the mapping is unambiguous. Base64 trades that clarity for compactness. Decimal is unusual in production but useful when you are checking whether a value really covers the full range, since you can see the individual numbers.
The C array format is a convenience for embedding a fixed value in source β a test vector, a known-answer check, a hard-coded initialisation vector in a unit test. It should not be how a production key reaches your program; keys belong in a secret store or an environment variable, not in a repository.
Where this tool fits
It is well suited to development and testing: generating a fixture key, producing a salt to work through an example, checking that your code handles a full-range byte value. For production secrets, the safest route is to generate them where they will live, because a value that appears on a screen and passes through a clipboard has had more exposure than one that never left the server.
Privacy
Bytes are generated in your browser and stay there. Nothing is transmitted, stored, logged or included in the page URL.
How to use the Random Bytes Generator
- Set how many bytes you need. Sixteen bytes is 128 bits, thirty-two bytes is 256 bits.
- Choose a format β hex for general use, a C array to paste into source, Base64 for transport, decimal for inspection.
- Generate, then copy the value or download it.
Frequently asked questions
What are random bytes used for?
They are the raw material behind most cryptographic values: encryption keys, salts for password hashing, initialisation vectors, nonces, and the entropy behind tokens and identifiers. Anywhere a specification says "a random value of n bytes", this is what it means.
How many bytes do I need?
It depends on the use. A symmetric key is normally 16 or 32 bytes. A salt for password hashing is typically 16. An AES-GCM initialisation vector is 12 bytes, and reusing one with the same key is a serious flaw, so generate a fresh one each time. When a specification names a size, use exactly that size.
Are these bytes suitable for cryptographic keys?
The randomness is β crypto.getRandomValues is the same source a browser uses for its own cryptography. The surrounding process is the weak point: the value is displayed on screen and probably passes through your clipboard. For a production key, generating it inside the system that will use it avoids that exposure entirely.
What is the difference between the output formats?
They are the same bytes written differently. Hex gives two characters per byte and is the most portable. Spaced hex is easier to read when checking a value by eye. Base64 is more compact for transport. Decimal shows the numeric value of each byte, which helps when debugging. The C array format is ready to paste into source code.
Why does Base64 output look longer than the byte count?
Base64 encodes three bytes as four characters, so the text is about a third longer than the data it carries. The entropy is unchanged β 32 bytes remains 256 bits whether you write it as 64 hex characters or about 44 Base64 characters.
Can I generate the same bytes again?
Only in seeded mode, where a given seed always reproduces the same sequence. That is useful for reproducible tests. Never use seeded mode for a real key: anyone holding the seed can regenerate it exactly.
Is there a limit on how many bytes I can generate?
The tool caps a single request at 1024 bytes, which is far above any normal cryptographic use and keeps the page responsive. If you need bulk random data β filling a test file, for example β a command-line tool reading from the operating system's random device is the right instrument.