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 ;
7 TUPLE: unix-random reader ;
9 : <unix-random> ( path -- random )
10 binary <file-reader> unix-random boa ;
12 M: unix-random random-bytes* ( n tuple -- byte-array )
13 reader>> stream-read ;
17 "/dev/srandom" <unix-random> secure-random-generator set-global
18 "/dev/arandom" <unix-random> system-random-generator set-global
19 ] "random.unix" add-init-hook
22 "/dev/random" <unix-random> secure-random-generator set-global
23 "/dev/urandom" <unix-random> system-random-generator set-global
24 ] "random.unix" add-init-hook