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