---
name: "libressl-RAND_bytes"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-RAND_bytes"
---

# libressl-RAND\_bytes(3)

generate random data

## NAME

**RAND\_bytes**, **RAND\_pseudo\_bytes** – generate random data

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/rand.h\>**

*int*\

**RAND\_bytes**(*unsigned char \*buf*, *int num*);

*int*\

**RAND\_pseudo\_bytes**(*unsigned char \*buf*, *int num*);

## DESCRIPTION

These functions are deprecated and only retained for compatibility with legacy application programs. Use [arc4random\_buf(3)](/arc4random_buf/3.md) instead.

**RAND\_bytes**() puts *num* cryptographically strong pseudo-random bytes into *buf*.

**RAND\_pseudo\_bytes**() puts *num* pseudo-random bytes into *buf*. Pseudo-random byte sequences generated by **RAND\_pseudo\_bytes**() will be unique if they are of sufficient length, but are not necessarily unpredictable. They can be used for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc.

## RETURN VALUES

**RAND\_bytes**() returns 1. **RAND\_pseudo\_bytes**() returns 1.

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