RAND_BYTES(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸŽ€ RAND_BYTES(3) πŸŽ€

okay so bestie, you found the RAND_BYTES(3) page β€” it lives in the Library Functions Manual corner of the universe, and honestly? it's giving "vintage". let's get into it πŸ’…


✨ NAME ✨

RAND_bytes, RAND_pseudo_bytes β€” generate random data 🎲✨


🌈 SYNOPSIS 🌈

this one's from the library β€œlibcrypto”, and you'll be pulling in:

#include <openssl/rand.h>

and here are the two icons themselves, exactly as written:

int
RAND_bytes(unsigned char *buf, int num);

int
RAND_pseudo_bytes(unsigned char *buf, int num);

πŸ’– DESCRIPTION πŸ’–

🚨 heads up bestie: these functions are deprecated and only retained for compatibility with legacy application programs. use arc4random_buf(3) instead. periodt. πŸ’€

RAND_bytes() puts num cryptographically strong pseudo-random bytes into buf. πŸ”₯ like, actually strong. main character randomness.

RAND_pseudo_bytes() puts num pseudo-random bytes into buf. here's the tea though β€” pseudo-random byte sequences generated by RAND_pseudo_bytes() will be unique if they're of sufficient length, but they are not necessarily unpredictable. 😭 so basically: fine for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc. do not come for me if you use it for keys, i warned you. πŸ™ˆ


πŸ¦‹ RETURN VALUES πŸ¦‹

  • RAND_bytes() returns 1. ✨
  • RAND_pseudo_bytes() returns 1. ✨

yes both. always 1. slay, consistency. πŸ‘‘


🌸 HISTORY 🌸

RAND_bytes() first appeared in SSLeay 0.5.1 and has been available since OpenBSD 2.4. It has a return value since OpenSSL 0.9.5 and OpenBSD 2.7. πŸ•°οΈ

RAND_pseudo_bytes() first appeared in OpenSSL 0.9.5 and has been available since OpenBSD 2.7. 🫢


okay that's the whole page, no notes πŸ’œ this lil doc is brought to you by Debian, dated June 8, 2025 β€” shoutout to the packagers, they ate and left no crumbs πŸŽ€βœ¨ bye bestie, go use arc4random_buf(3) i'm begging 🧚

πŸ“¦ where this page comes from