4 ms·
> Far better would be the snippet of Common Lisp that reads random from getrandom(), and then /dev/urandom. Yup. Here's an example of the latter (I don't have
by zeveb 10y ago
> Far better would be the snippet of Common Lisp that reads random from getrandom(), and then /dev/urandom.
Yup. Here's an example of the latter (I don't have getrandom(2) on my machine):
(defun random-bytes (len)
(declare (type (integer 1) len))
(with-open-file (rand "/dev/urandom" :element-type 'unsigned-byte)
(let ((buf (make-array len :element-type 'unsigned-byte)))
(read-sequence buf rand)
buf)))
N.b.: I dashed this off quickly. Do not rely on it for security-sensitive code. Do not bet your life on it.