summaryrefslogtreecommitdiffstats
path: root/random.tl
blob: cd2eb90c087b4719f7047211c3172078b90d0cf2 (plain)
1
2
3
4
5
6
7
8
(defun get-urand-num (noctets)
  (with-stream (s (open-file "/dev/urandom"))
    (reduce-left (op + (* @1 256) @2) (take noctets (gun (get-byte s))))))

(defun randomize ()
  (set *random-state* (make-random-state (get-urand-num 8) 128)))

(defun save-random-state ())