| 1 | package Crypt::Perl::RNG; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Bytes::Random::Secure::Tiny (); | ||
| 7 | |||
| 8 | my %PID_RNG; | ||
| 9 | |||
| 10 | sub _get { | ||
| 11 | return $PID_RNG{$$} ||= Bytes::Random::Secure::Tiny->new(); | ||
| 12 | } | ||
| 13 | |||
| 14 | sub bytes { | ||
| 15 | return _get()->bytes(@_); | ||
| 16 | } | ||
| 17 | |||
| 18 | sub bytes_hex { | ||
| 19 | return _get()->bytes_hex(@_); | ||
| 20 | } | ||
| 21 | |||
| 22 | sub bit_string { | ||
| 23 | my ($count) = @_; | ||
| 24 | |||
| 25 | return _get()->string_from('01', $count); | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; |