Standard C Library (libc, -lc)
#include
    <unistd.h>
int
  
  getentropy(void
    *buf, size_t
    buflen);
getentropy()
    fills a buffer with high-quality random data.
The maximum buflen permitted is 256
  bytes.
If it does not produce an error,
    getentropy()
    always provides the requested number of bytes of random data.
Similar to reading from
    /dev/urandom just after boot,
    getentropy()
    may block until the system has collected enough entropy to seed the
  CSPRNG.
The getentropy() function is implemented
    using
    getrandom(2).
Upon successful completion, the value 0 is returned;
    otherwise the value -1 is returned and the global variable
    errno is set to indicate the error.
getentropy() will succeed unless:
  - [EFAULT]
- The buf parameter points to an invalid address.
- [EINVAL]
- Too many bytes requested.
getentropy() conforms to
    IEEE Std 1003.1-2024 (“POSIX.1”).
The getentropy() function appeared in
    OpenBSD 5.6. The FreeBSD
    libc compatibility shim first appeared in FreeBSD
    12.0.