aboutsummaryrefslogtreecommitdiff
path: root/tools/test/devrandom/hammer.random
blob: 0aee741e2c8c9d8a04e0871e1b873fb7b876daf3 (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.
#
# $FreeBSD: src/tools/test/devrandom/hammer.random,v 1.4 1999/08/28 00:54:24 peter 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";
	}
}