LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] how to answer the question: "how random?"

[ILUG] how to answer the question: "how random?"

Fergal Daly fergal at esatclear.ie
Sun Apr 29 16:33:32 IST 2001


perl -e 'sysread(STDIN, $r, 4); print unpack("L", $r)."\n"' < /dev/random

prints a random number between 0 and 2^32-1
replace the 4 and L to get different ranges:
2, S gives 0 to 65535
1, C gives 0 to 255


On Sat, Apr 28, 2001 at 12:46:58PM +0100, kevin lyda wrote:
> On Sat, Apr 28, 2001 at 11:34:18AM +0100, Conor Daly wrote:
> > Errm,  so, how do I get numbers form /dev/random?  dd gives me ascii
> > garbage, so does cat.  Do I need to write a c proggie to read and what
> > should I read then?
> 
> an ugly pipeline:
> 
> dd if=/dev/urandom bs=10 count=1 2> /dev/null| od -x | sed 's/^[^ ]* *//'
> 
> play with flags to od to change the radix, change the bs= setting for dd
> to get different sized numbers.  oh, and i used /dev/urandom to generate
> the numbers as it always returns the amount requested (at the price of
> less randomness).
> 
> kevin
> 
> -- 
> kevin at suberic.net          CERT CA-96.13/NiftyGreenShield: ... Impact:
> fork()'ed on 37058400      Non-privileged primitive users can cause the
> meatspace place: home      total destruction of your entire invasion fleet
> http://suberic.net/~kevin  and gain unauthorized access to files. ...
> 
> -- 
> Irish Linux Users' Group: ilug at linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at linux.ie

-- 




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell