I read about the Quantum Random Bit Generator Service the other day on slashdot. The service is offered for free with a quick registration at http://random.irb.hr/ They provide the source code and Windows and Linux binaries to connect to the service and retrieve some random data.
Earlier that day I was marveling at the availability of a Perl module to interface with just about anything. I thought it seemed like a good opportunity to write one for this new service. They provided some C source code, so I figured that I should be able to read through it well enough to understand what it was doing.
The interface that they provide is just a raw TCP connection. You have to send some header information including your username and password as well as the number of bytes of data you are requesting. It then sends back a bunch of random bits, and then I transform that into whatever type of numbers you want.
It ended up taking me entirely too long to implement, but I had dedicated enough time to it that I felt pretty committed. I read through the provided C code, and did a bunch of tcpdumps to capture the traffic that their working program sent and made sure that mine matched it bit by bit. Eventually I got it working. I’ve packaged into a module that I’m calling Data::Random::QRBGS. Now, it is simple to get some random data from the service like this:
use Data::Random::QRBGS; $qrbgs = new Data::Random::QRBGS('username', 'password'); @ints = $qrbgs->get(4); print "Got random integers: @intsn"; @shorts = $qrbgs->get(2, 's'); print "Got random shorts: @shortsn"; $bytes = $qrbgs->getraw(1024);
I’ve created a page at http://www.brandonchecketts.com/qrbgs.php that contains a little documentation and a link to download it.
I’d like to see about getting the module made available through CPAN, but it is actually turning out to be quite complicate to do that. I’ve requested an account, and I guess that has to get approved manually. They instructions recommend joining the mailing list and discussing the module for a while before before actually submitting it. I’ll get around to that as I have time I guess.