Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Genuine Quantum Randomness

by John M. Dlugosz (Monsignor)
on Jun 01, 2001 at 19:54 UTC ( #84971=CUFP: print w/ replies, xml ) Need Help??

Well, I think it's pretty cool, but I've always liked physics. Chaotic systems are just like pseudorandom numbers only you don't know the seed. But quantum processes can be genuinly random and fundimentally unpredictable.

Fourmilab, where atom-smashing geeks dwell, has a cute toy in the basement. It generates true random numbers based on radioactive decay, and makes data available to the public.

They have a Java package to programmatically access it, but I wanted to do it in Perl. So I wrote a simple Perl module to access the server. I don't know how useful this is for most folks, but hey, it's cool!

—John
(code follows)

sample program

use strict; use warnings; use HotBits; my $x= new HotBits::; my $bits= $x->request (16); # parameter is bytes to fetch, up to 2048 +. print length($bits)," bytes: "; print unpack("H*", $bits), "\n";

HotBits.pm

=head1 NAME B<HotBits> - download hardware random numbers =head1 AUTHOR John M. Dlugosz - john@dlugosz.com - http://www.dlugosz +.com =head1 DESCRIPTION This module will access "genuine" random numbers via http://www.fourmi +lab.ch/hotbits/. This server at Fourmilab in Switzerland uses radioactive decay to offe +r the truest random number source possible. This module works the same as the site's Java + class for the same purpose: access the CGI program via HTTP. =cut package HotBits; use strict; use warnings; our $VERSION= v1.0; require LWP::UserAgent; use Carp; my $serverURL='http://www.fourmilab.ch/cgi-bin/uncgi/Hotbits'; sub new { my $class= shift; my $URL= shift || $serverURL; # optional argument my $ua = new LWP::UserAgent::; $ua->env_proxy(); my $self= bless { ua => $ua, URL => $URL }, $class; return $self; } sub request { my ($self, $count)= @_; $count ||= 128; my $request = HTTP::Request->new('GET', "$self->{URL}?nbytes=$count&f +mt=bin"); $request->proxy_authorization_basic($ENV{HTTP_proxy_user}, $ENV{HTTP_ +proxy_pass}) if $ENV{HTTP_proxy_user}; my $response = $self->{ua}->request($request); croak "Error from $self->{URL}", if ($response->code() != 200); croak "Unexpected return (not binary) from $self->{URL}" if $response +->headers()->content_type() ne "application/octet-stream"; return $response->content(); } 1; # module loaded OK.

Comment on Genuine Quantum Randomness
Select or Download Code
Re: Genuine Quantum Randomness
by dws (Chancellor) on Jun 01, 2001 at 23:03 UTC
    For another random number generator based on a chaotic system (lava lamps), see http://lavarand.sgi.com/.

    This wins points in my book for one of the coolest applications of lava lamp technology.

    Update: They're defunct. Poo.

      I looked at lavaland just the other day, and it seems to be defunct. No updates in a couple years, and plans for stuff that may get done during 2000. Can't get any freshly generated random data from them.

      If I were to build something, I think a radio tuned to no station, patched to the mic input on a sound card would be a good and cheap chaos sampler.

      How does the random number generator in Perl's rand work? It seems pretty good, and I remember years ago reading that they no longer use the C library's generator.

      —John

        From the perldelta for v5.6.0:

        Better pseudo-random number generator
        In 5.005_0x and earlier, perl's rand() function used the C library rand(3) function. As of 5.005_52, Configure tests for drand48(), random(), and rand() (in that order) and picks the first one it finds.

        These changes should result in better random numbers from rand().

        ~monk d4vis
        #!/usr/bin/fnord

Re: Genuine Quantum Randomness
by knobunc (Pilgrim) on Jun 04, 2001 at 16:39 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://84971]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-20 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls