OPENSSL-RAND(1SSL)

πŸ’– OPENSSL-RAND πŸ’–

ok bestie, welcome to openssl-rand from the OpenSSL crew β€” the lil glow-up corner of the openssl(1) fam whose entire job is generating pseudo-random bytes. yes. that's it. that's the gig. and it ATE. ✨


🌈 SYNOPSIS 🌈

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

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so basically this command generates num random bytes using a cryptographically secure pseudo random number generator (CSPRNG) β€” like, not the fake gamer random, the actual secure one, she's a queen fr fr. πŸ‘‘

and here's the cute part: you can slap a suffix [K|M|G|T] on the end of your num value to say "hey bestie, scale this as a multiple of KiB/MiB/GiB/TiB respectively". but watch out β€” the suffixes are case sensitive, and they mean binary multiples, not the marketing ones. so:

  • K = 1024 bytes
  • M = 1024*1024 bytes
  • etc πŸ’…

You can also just say the string 'max' instead of a number in num, which requests the maximum number of bytes the CSPRNG can produce per instantiation. rn that's restricted to 2^61 bytes as per NIST SP 800-90C. that's a lot of bytes bestie, hydrate.

The random bytes come courtesy of the RAND_bytes(3) function, which brings a security level of 256 bits, provided it managed to seed itself successfully from a trusted operating system entropy source. and if it didn't? 😭 it does not power through. the command fails with a nonzero error code. no vibes, no bytes. For more details, see RAND_bytes(3), RAND(7), and EVP_RAND(7).


✨ OPTIONS ✨

  • -help β€” prints out a usage message. cute, informative, supportive. 🫢
  • -out file β€” writes to file instead of standard output.
  • -base64 β€” does base64 encoding on the output. aesthetic bytes. ✨
  • -hex β€” shows the output as a hex string. very hacker-coded, we love.
  • -rand files, -writerand file β€” see "Random State Options" in openssl(1) for the details, bestie i'm not retyping all that.
  • -provider name
  • -provider-path path
  • -provparam [name:]key=value
  • -propquery propq

β€” see "Provider Options" in openssl(1), provider(7), and property(7). iykyk 🧚


πŸ‘€ SEE ALSO πŸ‘€

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


πŸ“œ HISTORY πŸ“œ

not me just finding out the -engine option was removed in OpenSSL 4.0. rip to a real one, fr fr. πŸ’€


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

okay bye bestie, go generate some bytes responsibly πŸ’œ

muah, this was OPENSSL-RAND(1SSL) from OpenSSL version 4.0.3, dated 2026-09-29. stan. πŸ’…

πŸ“¦ where this page comes from