inst/doc/secure_rng.R

## ---- echo = FALSE, message = FALSE-------------------------------------------
knitr::opts_chunk$set(comment = "")
library(openssl)

## -----------------------------------------------------------------------------
rnd <- rand_bytes(10)
print(rnd)

## -----------------------------------------------------------------------------
as.numeric(rnd)

## -----------------------------------------------------------------------------
x <- rand_bytes(1)
as.logical(rawToBits(x))

## -----------------------------------------------------------------------------
rand_num(10)

## -----------------------------------------------------------------------------
# Secure rnorm
x <- qnorm(rand_num(1000), mean = 100, sd = 15)
hist(x)

## -----------------------------------------------------------------------------
# Secure rbinom
y <- qbinom(rand_num(1000), size = 20, prob = 0.1)
hist(y, breaks = -.5:(max(y)+1))

Try the openssl package in your browser

Any scripts or data that you put into this service are public.

openssl documentation built on Sept. 26, 2023, 1:09 a.m.