- SEE ALSO
- COPYRIGHT AND LICENSE
Unix::OpenBSD::Random - interface to arc4random(3) on OpenBSD
use Unix::OpenBSD::Random qw(arc4random arc4random_uniform); my $x = arc4random(); my $y = arc4random(2); # coinflip
This module is a wafer-thin wraper around the arc4random(3) library function on OpenBSD. Other OS have this function call though may require arc4random_stir(3) or such calls that this module does not support.
Returns an integer in the
- arc4random_buf length
Returns a string filled with the given number of bytes of random data. This string may contain non-printable or even
NULcharacters so might best be converted to some other form before being displayed or used where such characters may cause problems.
my $buf = arc4random_buf(8); printf "%vx\n", $buf; my $string = unpack "H*", $buf;
Will throw an exception if the length is outside the range of a
Note that this interface has been made more Perl-like than the C version
- arc4random_uniform upper_bound
Returns an integer no more than the upper_bound. Avoids modulo bias. Will throw an exception if upper_bound is outside the range of allowed values for
Please report any bugs or feature requests to
bug-unix-openbsd-random at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Unix-OpenBSD-Random.
Patches might best be applied towards:
The newly being written thing and lack of testing on 32-bit systems. Lack of XS skill on the part of the author.
0 as an upper bound (and
arc4random_buf a length of
0). If this is a problem add a check before calling into this module.
thrig - Jeremy Mates (cpan:JMATES)
<jmates at cpan.org>
Copyright (C) 2018 by Jeremy Mates
This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause