1 ! Copyright (C) 2008 Doug Coleman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types io io.files kernel namespaces random
4 io.encodings.binary init accessors system destructors ;
7 TUPLE: unix-random reader ;
9 : <unix-random> ( path -- random )
10 binary <file-reader> unix-random boa ;
12 M: unix-random dispose reader>> dispose ;
14 M: unix-random random-bytes* ( n tuple -- byte-array )
15 reader>> stream-read ;
18 "/dev/random" <unix-random> &dispose secure-random-generator set-global
19 "/dev/urandom" <unix-random> &dispose system-random-generator set-global
20 ] "random.unix" add-startup-hook