1*d82e2864SMark Murray#!/usr/bin/perl 2*d82e2864SMark Murray 3*d82e2864SMark Murray# 4*d82e2864SMark Murray# Perform primitive binning into 16-bit bins (take 16bits of randomness 5*d82e2864SMark Murray# at a time) and see if the distribution is flat. The output should be 6*d82e2864SMark Murray# checked by eye - are all the numbers roughly the same? 7*d82e2864SMark Murray# 8*d82e2864SMark Murray# Redirect the output from this to a file - and go to the movies while 9*d82e2864SMark Murray# it runs. This program is a CPU Hog! 10*d82e2864SMark Murray# 11*d82e2864SMark Murray# 12*d82e2864SMark Murray 13*d82e2864SMark Murrayfor ($i = 0; $i < (1024*64); $i++) { 14*d82e2864SMark Murray open(BIN, "/dev/urandom") || die "Cannot open /dev/urandom - $!\n"; 15*d82e2864SMark Murray $len = sysread(BIN, $a, 512); 16*d82e2864SMark Murray close(BIN); 17*d82e2864SMark Murray if ($len > 0) { 18*d82e2864SMark Murray for ($j = 0; $j < $len; $j += 2) { 19*d82e2864SMark Murray $k = unpack("S", substr($a, $j, 2)); 20*d82e2864SMark Murray $bin[$k]++; 21*d82e2864SMark Murray } 22*d82e2864SMark Murray } 23*d82e2864SMark Murray} 24*d82e2864SMark Murray 25*d82e2864SMark Murrayfor ($i = 0; $i < 1024*64; $i++) { 26*d82e2864SMark Murray printf("%.2X ", $bin[$i]); 27*d82e2864SMark Murray} 28*d82e2864SMark Murrayprintf "\n"; 29