openssl (version 0.2)

rand_bytes: Generate random bytes with OpenSSL

Description

Generate random bytes with OpenSSL

Usage

rand_bytes(n = 1)

rand_pseudo_bytes(n = 1)

Arguments

n
number of random bytes to generate

References

OpenSSL manual: https://www.openssl.org/docs/crypto/RAND_bytes.html

Examples

Run this code
rnd <- rand_bytes(10)
as.numeric(rnd)
as.character(rnd)
as.logical(rawToBits(rnd))

# numbers range from 0 to 255
rnd <- rand_bytes(100000)
hist(as.numeric(rnd), breaks=-1:255)

# Generate random doubles between 0 and 1
rand_num(5)

Run the code above in your browser using DataLab