RAND_BYTES(3)
π 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()returns1. β¨RAND_pseudo_bytes()returns1. β¨
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
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms