My jprofile has included a script for several years useful in Linux and OS X - the name (pgseed) stands for PrettyGoodSeed

   pgseed
3 : '9!:1 {. _2 (3!:4) (4?4){ host ''dd if=/dev/random bs=4 count=1'''

   host
[: 2!:0 '(' , ' || true)' ,~ ]

   pgseed ''
1+0 records in
1+0 records out
4 bytes transferred in 0.000034 secs (117323 bytes/sec)

This "noise of standard output" doesn't bother my use of the above since I use it primarily in CGI scripts.

The host verb is a nice cover (thanks to Martin Neitzel) for 2!:0

Unix utility dd is a very low level way to read stream files. The stuff operating on the result of the call via host is a bit over the top, but I do believe this provides a pretty good seed, and doesn't drink much from the entropy pool.


On 2013/03/13 09:17 , bill lam wrote:
You may remove the newline at the end and convert the string
into a number, eg

    ". LF-.~ 2!:0 'cat /dev/urandom|od -N4 -An -i'
1281601434

long may be use in J64

    0". LF-.~  2!:0 'cat /dev/urandom|od -N8 -An -l'
8774956622310178816


Ср, 13 мар 2013, Brian Schott писал(а):
Bill,

Your approach produced the following results on my Mac OS X. Notice
the two blank lines and the negative number result.

    2!:0 'cat /dev/urandom|od -N4 -An -i'
                 818045955


    2!:0 'cat /dev/urandom|od -N4 -An -i'
               -1293144445



--
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to