aboutsummaryrefslogtreecommitdiff
path: root/tools/test/devrandom/hammer.random
blob: a3d439471ee827051b71d6a344add0b0fb5815c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl

#
# Test program for /dev/random
# Read and display random numbers.
# Try tapping shift/alt/ctrl to get more randomness.
#
# $Id: hammer.random,v 1.1 1995/11/04 09:50:41 markm Exp $
#

for (;;) {
	open(BIN, "/dev/random") || die "Cannot open /dev/random - $!\n";
	$len = sysread(BIN, $a, 128);
	close(BIN);
	if ($len > 0) {
		print "$len bytes read: ";
		for ($j = 0; $j < $len; $j++) {
			$k = unpack("C", substr($a, $j, 1));
			printf("%.2X ", $k);
		}
		printf "\n";
	}
}