freebsd-dev/tools/test/devrandom/stat.8bit
Jordan K. Hubbard 1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00

30 lines
690 B
Plaintext

#!/usr/bin/perl
#
# Perform primitive binning into 8-bit bins (take 8 bits of randomness
# at a time) and see if the distribution is flat. The output should be
# checked by eye - are all the numbers roughly the same?
#
# Redirect the output from this to a file - and make a cup of coffee while
# it runs. This program is a CPU Hog!
#
# $FreeBSD$
#
for ($i = 0; $i < (1024*32); $i++) {
open(BIN, "/dev/urandom") || die "Cannot open /dev/urandom - $!\n";
$len = sysread(BIN, $a, 256);
close(BIN);
if ($len > 0) {
for ($j = 0; $j < $len; $j++) {
$k = unpack("C", substr($a, $j, 1));
$bin[$k]++;
}
}
}
for ($i = 0; $i < 256; $i++) {
printf("%.2X ", $bin[$i]);
}
printf "\n";