xref: /freebsd/tools/test/devrandom/hammer.random (revision 1719886f6d08408b834d270c59ffcfd821c8f63a)
1#!/usr/bin/perl
2
3#
4# Test program for /dev/random
5# Read and display random numbers.
6# Try tapping shift/alt/ctrl to get more randomness.
7#
8#
9
10for (;;) {
11	open(BIN, "/dev/random") || die "Cannot open /dev/random - $!\n";
12	$len = sysread(BIN, $a, 128);
13	close(BIN);
14	if ($len > 0) {
15		print "$len bytes read: ";
16		for ($j = 0; $j < $len; $j++) {
17			$k = unpack("C", substr($a, $j, 1));
18			printf("%.2X ", $k);
19		}
20		printf "\n";
21	}
22}
23