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