OPENSSL-RAND(1ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

✨ OPENSSL-RAND(1ossl) ✨

okay bestie so you're here because you want random bytes and you want them now πŸ’– this page is from the OpenSSL fam, and honestly? it's a little icon. let's get into it.


🌸 NAME 🌸

openssl-rand β€” generate pseudo-random bytes, no cap πŸ’…


πŸ¦‹ 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]

πŸŽ€ DESCRIPTION πŸŽ€

so basically this command generates num random bytes using a cryptographically secure pseudo random number generator (CSPRNG) ✨ like, the good kind of random, not vibes-based random.

you can slap a suffix [K|M|G|T] onto the num value to ask for a scaled-up amount β€” the number you give gets multiplied by KiB/MiB/GiB/TiB respectively 🫢. tiny detail but so important: suffixes are case sensitive, and they're binary multiples, so K = 1024 bytes, M = 1024*1024 bytes, etc. lowercase k does NOT get the same treatment, bestie, watch out πŸ‘€

the string 'max' is also allowed in place of a numerical value in num β€” it's the way you ask for the absolute maximum number of bytes the CSPRNG can produce per instantiation πŸ”₯ Currently (as of right now, no cap) that's restricted to 2^61 bytes as per NIST SP 800-90C.

the random bytes come from the RAND_bytes(3) function, which gives you a security level of 256 bits β€” but only if it managed to seed itself successfully from a trusted operating system entropy source 🌈. otherwise? the command fails with a nonzero error code. πŸ’€ periodt. for more deets see RAND_bytes(3), RAND(7), and EVP_RAND(7).


πŸ’œ OPTIONS πŸ’œ

  • -help β€” prints out a usage message, the classic. πŸ™Œ
  • -out file β€” write to file instead of standard output, so it doesn't just spill everywhere πŸ“
  • -base64 β€” performs base64 encoding on the output πŸ’…
  • -hex β€” shows the output as a hex string ✨
  • -engine id β€” see "Engine Options" in openssl(1). 🚨 this option is deprecated, just so you know.
  • -rand files, -writerand file β€” see "Random State Options" in openssl(1) for the details 🫢
  • -provider name β€” provider stuff, see the group below πŸ‘‡
  • -provider-path path β€” same little provider fam, see openssl(1), provider(7), and property(7) πŸ¦‹
  • -provparam [name:]key=value β€” provider parameter, all the deets in those same pages 🌸
  • -propquery propq β€” property query, again: see "Provider Options" in openssl(1), provider(7), and property(7) πŸ’–
ngl the provider options are all documented in one bundle in the original β€” they all point at "Provider Options" in openssl(1), plus provider(7) and property(7). iykyk πŸ’«

🌟 SEE ALSO 🌟

openssl(1), RAND_bytes(3), RAND(7), EVP_RAND(7) πŸ‘‘


🧚 HISTORY 🧚

the -engine option was deprecated in OpenSSL 3.0 β€” so like, it's giving legacy, we don't really do that anymore 🫠


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>.


and that's the whole vibe check, bestie β€” this page ate and left no crumbs πŸ’…βœ¨ this was version 3.5.6, dated 2026-04-07, manual name OPENSSL-RAND(1ossl), love u, go make some secure random bytes πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from