Robert A. Uhl

How to generate secure random numbers in Common Lisp

Paragon Initiative Enterprises wrote a nice blog entry on how to generate secure random numbers in various languages awhile back. They did leave out Common Lisp, but it’s easy to do there, too:

(ql:quickload "ironclad")
(crypto:random-data 32)     ;; → 32 random bytes
(crypto:random-bits 128)    ;; → 128-bit random integer
(crypto:strong-random 1024) ;; → random integer in (0, 1,024]
(crypto:strong-random 1.0)  ;; → random float in (0, 1.0]

I dropped them a line, so hopefully it’ll get updated soon.


Share