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

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Random number?

[ILUG] Random number?

kevin lyda kevin at suberic.net
Sun Feb 25 21:40:17 GMT 2001


On Sun, Feb 25, 2001 at 10:03:16PM +0000, Sean O'Riordain wrote:
> under more recent kernels >2.2? there is an entropy pool which is taken
> from things like disk activity etc... which is designed to be pretty
> random...  openssl will have routines to use it... no idea how to use it
> in a shell script though...

actually, 1.3.30 according to the random(4) man page.

very random:
#!/bin/sh
RANDOM=`dd if=/dev/random bs=1 count=2 2>/dev/null \
        | od -tu2 \
        | head -1 \
        | awk '{print $2}'`
echo $RANDOM

pretty random:
#!/bin/sh
RANDOM=`dd if=/dev/urandom bs=1 count=2 2>/dev/null \
        | od -tu2 \
        | head -1 \
        | awk '{print $2}'`
echo $RANDOM

it's also a one liner in perl, but that's cheating...  the former
will hang till entropy is deemed large enough, the latter will
do the best it can and quickly.

kevin

-- 
kevin at suberic.net        i...  i have a dream.  and that dream is:
fork()'ed on 37058400    use DIY::Tiler;
meatspace place: orbit   my($t) = new DIY::Tiler;
                         $t->tile(-room => "en-suite", -style => "stone");




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