jeroenooms/opencpu — pull request #107 by rubenarslan (2014-06-30 15:42:46+00:00)
Title: Use openssl's cryptographically secure RNG

So simply going straight to openssl seems to be the recommend course of action in a number of R packages dealing with cryptographically insecure RNG (e.g. [randaes](http://cran.r-project.org/web/packages/randaes/index.html) and [digest](http://cran.r-project.org/web/packages/digest/digest.pdf)).

Re #95 I proposed the necessary edits, but they would come at some cost, using openssl via system calls is ~176 times slower. Maybe the RNG generator could be pickable through a config option? In my case using cryptographically secure keys would really be imperative, but MMV. Maybe OpenCPU should default to the more secure version though...

```r
system.time({
for(i in 1:5000) {
hash <- paste0("x0", system( paste("openssl rand -hex",64/2), intern = T ) )
}
})
## user system elapsed
## 12.712 8.402 21.942
characters <- c(0:9, letters[1:6]);
system.time({
for(i in 1:5000) {
hash <- paste(c("x0", sample(characters, 64, replace=TRUE)), collapse="")
}
})
## user system elapsed
## 0.122 0.003 0.124
4.357/0.013
## [1] 176.9516
```