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 tofileinstead 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" inopenssl(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" inopenssl(1)for the details.-provider nameβ provider loading, see "Provider Options" inopenssl(1),provider(7), andproperty(7).-provider-path pathβ same crowd as above, go read "Provider Options" inopenssl(1),provider(7), andproperty(7).-provparam [name:]key=valueβ yeah you guessed it, "Provider Options" inopenssl(1),provider(7), andproperty(7).-propquery propqβ and again bestie, "Provider Options" inopenssl(1),provider(7), andproperty(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 π
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
- alpine 3.23: openssl-doc 3.5.9-r0 Β· Apache-2.0
- alpine 3.24: openssl-doc 3.5.9-r0 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms