Random Numbers in Perl

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: NathanSapernatedog@well.com
Date:  
Subject: Random Numbers in Perl
On Mon, Oct 23, 2000 at 05:17:03AM -0700, Jason wrote:
> Nathan Saper wrote:
> > Here's one for you Perl gurus out there:
> >
> > In a Perl app I'm trying to write, I want to be able to create random
> > hex integers $bits bits long, where $bits is a user-defined variable.
> > The randomness of the numbers needs to be as good as possible, because
> > it would be used in a crypto app.
> >
> > Any ideas?
>
> Do it in C, and have the perl script take the output.. Perl isnt
> really fast enough for this type of thing.
>


> I have this sinking sensation, however, that your wanting to do this
> for something that will be platform independant, and run on a
> webserver... which makes the above impossible. Hmmm..
>


Precisely.

> Anyways, heres a standalone application with a hard-coded number of
> bits... it at least works well enough that you can call it from a bash
> script to define a variable or some such..
>
> The weird code at the front of the program (the xbits, or extra bits,
> stuff) handles the event that the number of bits is NOT a multiple of
> four.. in these cases, the digit first printed must be the one with
> the limited range (0-7, 0-3, or 0-1) depending on the number of extra
> bits.
>


Thanks for the code. I'm gonna try to use some of those ideas in my script.

- --
Nathan Saper () | http://www.well.com/user/natedog/
GnuPG (ElGamal/DSA): 0x9AD0F382 | PGP 2.x (RSA): 0x386C4B91
Standard PGP & PGP/MIME OK      | AOL Instant Messenger: linuxfu