OPENSSL-RAND(1ossl)

✨ OPENSSL-RAND πŸ’… β€” like, the manual page for openssl-rand from the 1ossl manual, bestie ✨

okay so. you want random bytes. cryptographically random. not "my little brother picked a number" random. and this page (it's OPENSSL-RAND(1ossl), yes the 1ossl is the manual name, we stan a labeled section) is gonna tell you literally everything about it. let's go 🌈


πŸŽ€ SYNOPSIS πŸŽ€

openssl rand [-help] [-out file] [-base64] [-hex] [-engine id] [-rand
files] [-writerand file] [-provider name] [-provider-path path]
[-provparam [name:]key=value] [-propquery propq] num[K|M|G|T]

that's the whole vibe. num is the main character, everything in brackets is optional flair. πŸ’…


🌸 DESCRIPTION 🌸

so this command generates num random bytes using a cryptographically secure pseudo random number generator (CSPRNG). say that three times fast. no wait, don't, it's long.

you can tack a suffix [K|M|G|T] onto the num value to say "actually scale this as a multiple of KiB / MiB / GiB / TiB respectively." and listen, the suffixes are case sensitive β€” do not come in here with lowercase k and expect it to work, i don't make the rules. also the suffixes mean binary multiples, so K = 1024 bytes, M = 1024*1024 bytes, etc. iconic behavior honestly.

the string 'max' may be substituted for a numerical value in num β€” yes, you literally type the word max β€” to request the maximum number of bytes the CSPRNG can produce per instantiation. currently that's restricted to 2^61 bytes as per NIST SP 800-90C. so like, a lot. but still a limit, bestie, don't get cocky 🫢

the random bytes are generated using the RAND_bytes(3) function, which provides a security level of 256 bits, provided it managed to seed itself successfully from a trusted operating system entropy source. otherwise, the command will fail with a nonzero error code. huge emphasis on otherwise. for more deets, see RAND_bytes(3), RAND(7), and EVP_RAND(7).

ngl if the seeding fails you get an error, not garbage bytes pretending to be secure. respect the process. πŸ’€

πŸ’– OPTIONS πŸ’–

here's the menu, order it however, they're all valid:

  • -help β€” prints out a usage message. the "wait what were the flags again" button ✨
  • -out file β€” writes to file instead of standard output. like, put it somewhere, don't just let it spill everywhere πŸŽ€
  • -base64 β€” performs base64 encoding on the output. aesthetic AND portable.
  • -hex β€” shows the output as a hex string. classic, reliable, very "i read hex dumps for fun" of you πŸ¦‹
  • -engine id β€” see "Engine Options" in openssl(1). this option is deprecated, so like… it's giving vintage, and not in the cute way. πŸ™ˆ
  • -rand files, -writerand file β€” see "Random State Options" in openssl(1) for the details.
  • -provider name β€” provider loading, see "Provider Options" in openssl(1), provider(7), and property(7).
  • -provider-path path β€” same crowd as above, go read "Provider Options" in openssl(1), provider(7), and property(7).
  • -provparam [name:]key=value β€” yeah you guessed it, "Provider Options" in openssl(1), provider(7), and property(7).
  • -propquery propq β€” and again bestie, "Provider Options" in openssl(1), provider(7), and property(7). the provider girlies are all grouped together, it's a whole squad πŸ’œ

πŸ¦‹ SEE ALSO πŸ¦‹

openssl(1), RAND_bytes(3), RAND(7), EVP_RAND(7)

(the extended universe. go read them, they're like the prequels but actually good ✨)


⭐ HISTORY ⭐

the -engine option was deprecated in OpenSSL 3.0. we remember her fondly. mostly. πŸ’…


Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.

fr fr please actually read the license, "i didn't know" is not the energy we're going for 😭

okay that's the whole page!! this was the OpenSSL 3.5.9 version, dated 2026-09-29, from the OPENSSL-RAND(1ossl) manual β€” stay random, stay seeded, and hydrate before you hex-dump anything πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from