RAND_bytes

Fill a buffer with cryptographically strong random bytes from the public CSPRNG.

Synopsis

Declared in <openssl/rand.h>

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

Return Value

1 on success, -1 if not supported by the current RAND method, or 0 on other failure.

Parameters

NameDescription
bufBuffer that receives num random bytes.
numNumber of bytes to generate.