xref: /freebsd/tools/test/devrandom/hammer.random (revision 1130b656e5fe4c2d1ba299e024d1b40eaeebd380)
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# $FreeBSD$
9#
10
11for (;;) {
12	open(BIN, "/dev/random") || die "Cannot open /dev/random - $!\n";
13	$len = sysread(BIN, $a, 128);
14	close(BIN);
15	if ($len > 0) {
16		print "$len bytes read: ";
17		for ($j = 0; $j < $len; $j++) {
18			$k = unpack("C", substr($a, $j, 1));
19			printf("%.2X ", $k);
20		}
21		printf "\n";
22	}
23}
24