xref: /freebsd/tools/test/devrandom/hammer.random (revision 1669d8afc64812c8d2d1d147ae1fd42ff441e1b1)
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