Crypt-HSXKPasswd
view release on metacpan or search on metacpan
lib/Crypt/HSXKPasswd/RNG/Data_Entropy.pm view on Meta::CPAN
package Crypt::HSXKPasswd::RNG::Data_Entropy;
use parent Crypt::HSXKPasswd::RNG;
# import required modules
use strict;
use warnings;
use Carp; # for nicer 'exception' handling for users of the module
use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
use English qw( -no_match_vars ); # for more readable code
use Readonly; # for truly constant constants
use Type::Params qw( compile ); # for parameter validation with Type::Tiny objects
use Crypt::HSXKPasswd::Types qw( :types ); # for custom type checking
use Crypt::HSXKPasswd::Helper; # exports utility functions like _error & _warn
# set things up for using UTF-8
use 5.016; # min Perl for good UTF-8 support, implies feature 'unicode_strings'
use Encode qw(encode decode);
use utf8;
binmode STDOUT, ':encoding(UTF-8)';
# try import Data::Entropy::Algorithms
Readonly my $_CAN_DATA_ENTROPY => eval{
require Data::Entropy::Algorithms; # for random number generation
} || 0;
# Copyright (c) 2015, Bart Busschots T/A Bartificer Web Solutions All rights
# reserved.
#
# Code released under the FreeBSD license (included in the POD at the bottom of
# HSXKPasswd.pm)
#
# --- Constants ---------------------------------------------------------------
#
# version info
use version; our $VERSION = qv('1.2');
# utility variables
Readonly my $_CLASS => __PACKAGE__;
#
# --- Constructor -------------------------------------------------------------
#
#####-SUB-#####################################################################
# Type : CONSTRUCTOR (CLASS)
# Returns : An object of type Crypt::HSXKPasswd::RNG::Data_Entropy
# Arguments : NONE
# Throws : Croaks on invalid invocation and invalid args, or if the module
# Data::Entropy::Algorithms is not available
# Notes :
# See Also :
sub new{
my $class = shift;
_force_class($class);
# croak if Data::Entropy::Algorithms is not avaialble
unless($_CAN_DATA_ENTROPY){
_error('This RNG module requires Data::Entropy::Algorithms, which is not installed');
}
# bless and return an empty object
my $instance = {};
bless $instance, $class;
return $instance;
}
#
# --- Public Instance functions -----------------------------------------------
#
#####-SUB-#####################################################################
# Type : INSTANCE
# Purpose : Override the parent random_numbers() function and generate
# random numbers between 0 and 1.
( run in 0.771 second using v1.01-cache-2.11-cpan-39bf76dae61 )