view release on metacpan or search on metacpan
bin/hsxkpasswd view on Meta::CPAN
use File::HomeDir; # for finding the path to the user's home dir
use Types::Standard qw( :types ); # for basic type checking (Int Str etc.)
# include Crypt::HSXKPasswd Stuff
# DEV-ONLY
use lib './lib/';
use Crypt::HSXKPasswd;
use Crypt::HSXKPasswd::Types qw( :types );
# 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)';
# 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
# this file)
lib/Crypt/HSXKPasswd.pm view on Meta::CPAN
use Types::Standard qw( slurpy :types ); # for basic type checking (Int Str etc.)
use Crypt::HSXKPasswd::Types qw( :types ); # for custom type checking
use Crypt::HSXKPasswd::Helper; # exports utility functions like _error & _warn
use Crypt::HSXKPasswd::Dictionary::Basic;
use Crypt::HSXKPasswd::RNG::Math_Random_Secure;
use Crypt::HSXKPasswd::RNG::Data_Entropy;
use Crypt::HSXKPasswd::RNG::DevUrandom;
use Crypt::HSXKPasswd::RNG::Basic;
# 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 Text::Unidecode; # for stripping accents from accented characters
use utf8;
binmode STDOUT, ':encoding(UTF-8)';
# import (or not) optional modules
eval{
# the default dicrionary may not have been geneated using the Util module
require Crypt::HSXKPasswd::Dictionary::EN;
}or do{
lib/Crypt/HSXKPasswd.pm view on Meta::CPAN
my $ans = q{}.$chars[0].q{.}.$chars[1].$chars[2];
# then add the scientific notation bit
$ans .= 'x10^'.(scalar @chars - 1);
# return the result
return $ans;
}
#####-SUB-######################################################################
# Type : CLASS (PRIVATE)
# Purpose : Get the so-called 'grapheme length' of a unicode string, that is
# to say, the length of a word where a letter with an accent counts
# as a single letter.
# Returns : An integer
# Arguments : 1) the string to get the length of
# Throws : Croaks on invalid invocation and invalid args
# Notes : Perl, by default, will consider accented letters as having a
# length of two. This function uses a very common algorythm
# recommended all over the internet, including in the Perl Unicode
# cookbook: http://search.cpan.org/~shay/perl-5.20.2/pod/perlunicook.pod
# Before resorting to this technique, I tried to use the
lib/Crypt/HSXKPasswd/Dictionary.pm view on Meta::CPAN
use English qw( -no_match_vars ); # for more readable code
use Scalar::Util qw( blessed ); # for checking if a reference is blessed
use List::MoreUtils qw( uniq ); # for array deduplication
use Readonly; # for truly constant constants
use Types::Standard qw( :types slurpy ); # for data validation
use Type::Params qw( compile ); # for argument valdiation
use Crypt::HSXKPasswd::Types qw( :types ); # for data validation
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)';
# 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)
lib/Crypt/HSXKPasswd/Dictionary/Basic.pm view on Meta::CPAN
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 multisig ); # for parameter validation with Type::Tiny objects
use Types::Standard qw( :types ); # for basic type checking (Int Str etc.)
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)';
# 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)
lib/Crypt/HSXKPasswd/Dictionary/EN.pm view on Meta::CPAN
use strict;
use warnings;
use English qw( -no_match_vars ); # for more readable code
use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
use Readonly; # for truly constant constants
# HSXKPasswd stuff
use Crypt::HSXKPasswd::Helper;
# 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)';
#
# === Constants ===============================================================#
#
# version info
use version; our $VERSION = qv('3.002_001');
lib/Crypt/HSXKPasswd/Dictionary/ES.pm view on Meta::CPAN
use strict;
use warnings;
use English qw( -no_match_vars ); # for more readable code
use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
use Readonly; # for truly constant constants
# HSXKPasswd stuff
use Crypt::HSXKPasswd::Helper;
# 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)';
#
# === Constants ===============================================================#
#
# version info
use version; our $VERSION = qv('3.002_001');
lib/Crypt/HSXKPasswd/Dictionary/FR.pm view on Meta::CPAN
use strict;
use warnings;
use English qw( -no_match_vars ); # for more readable code
use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
use Readonly; # for truly constant constants
# HSXKPasswd stuff
use Crypt::HSXKPasswd::Helper;
# 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)';
#
# === Constants ===============================================================#
#
# version info
use version; our $VERSION = qv('3.002_001');
lib/Crypt/HSXKPasswd/Dictionary/NL.pm view on Meta::CPAN
use strict;
use warnings;
use English qw( -no_match_vars ); # for more readable code
use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
use Readonly; # for truly constant constants
# HSXKPasswd stuff
use Crypt::HSXKPasswd::Helper;
# 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)';
#
# === Constants ===============================================================#
#
# version info
use version; our $VERSION = qv('3.002_001');
lib/Crypt/HSXKPasswd/Dictionary/System.pm view on Meta::CPAN
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 Crypt::HSXKPasswd::Helper; # exports utility functions like _error & _warn
use Crypt::HSXKPasswd::Dictionary::Basic; # used to process the dictionary file
# 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)';
# 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)
lib/Crypt/HSXKPasswd/Helper.pm view on Meta::CPAN
use warnings;
use English qw( -no_match_vars );
use Carp; # for nicer 'exceptions' for users of the module
use Fatal qw( :void open close binmode ); # make builtins throw exceptions
use Scalar::Util qw( blessed ); # for checking if a reference is blessed
use List::MoreUtils qw( uniq ); # for array deduplication
use Readonly; # for truly constant constants
use Types::Standard qw( ClassName ); # needed for _force_class
# 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)';
## no critic (ProhibitAutomaticExportation);
use base qw( Exporter );
our @EXPORT = qw( _do_debug _debug _warn _error _force_class _force_instance );
## use critic
# import (or not) optional modules
lib/Crypt/HSXKPasswd/RNG.pm view on Meta::CPAN
# 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 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)';
# 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)
lib/Crypt/HSXKPasswd/RNG/Basic.pm view on Meta::CPAN
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)';
# 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)
lib/Crypt/HSXKPasswd/RNG/Data_Entropy.pm view on Meta::CPAN
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
lib/Crypt/HSXKPasswd/RNG/DevUrandom.pm view on Meta::CPAN
use warnings;
use Carp; # for nicer 'exception' handling for users of the module
use Fatal qw( :void open close binmode sysread ); # 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)';
# 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)
lib/Crypt/HSXKPasswd/RNG/Math_Random_Secure.pm view on Meta::CPAN
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_MATH_RANDOM_SECURE => eval{
require Math::Random::Secure; # for random number generation
} || 0;
# Copyright (c) 2015, Bart Busschots T/A Bartificer Web Solutions All rights
lib/Crypt/HSXKPasswd/RNG/RandomDotOrg.pm view on Meta::CPAN
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::Tiny; # for creating anonymous type definitions
use Type::Params qw( compile ); # for parameter validation with Type::Tiny objects
use Types::Standard qw( :types slurpy ); # for standard types like Str and Int etc.
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)';
# import (or not) modules not listed as required by Crypt::HSXKPasswd
Readonly my $_CAN_EMAIL_VALID => eval{
require Email::Valid; # for email address validation
} || 0;
Readonly my $_CAN_URI => eval{
require URI; # for assembling the query to the random.org API
lib/Crypt/HSXKPasswd/Types.pm view on Meta::CPAN
use warnings;
use English qw( -no_match_vars );
use Carp; # for nicer 'exceptions' for users of the module
use Fatal qw( :void open close binmode ); # make builtins throw exceptions
use List::MoreUtils qw( uniq );
use Data::Dumper; # for generating sane error messages
use Type::Tiny;
use Types::Standard qw( :types );
# 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)';
#==============================================================================#
# Custom Type Library for Crypt::HSXKPasswd
#==============================================================================#
#
# A library of custom Type::Tiny types for use in the various Crypt::HSXKPasswd
# packages.
lib/Crypt/HSXKPasswd/Types.pm view on Meta::CPAN
},
message => sub{
return var_to_string($_).qq{ is not a Word (must be $WORD_ENGLISH)};
},
my_methods => {
english => sub {return $WORD_ENGLISH;},
},
);
__PACKAGE__->meta->add_type($WORD);
# add a type for a single symbol (a single non-letter unicode grapheme)
my $SYMBOL_ENGLISH = 'a string containing exactly one non-letter character';
my $SYMBOL = Type::Tiny->new(
name => 'Symbol',
parent => Str,
constraint => sub{
return m/^\X$/sx && m/^[^\pL]$/sx;
},
message => sub{
return var_to_string($_).qq{ is not a Symbol (must be $SYMBOL_ENGLISH)};
},
lib/Crypt/HSXKPasswd/Util.pm view on Meta::CPAN
use Readonly; # for truly constant constants
use Scalar::Util qw(blessed); # for checking if a reference is blessed
use Type::Tiny; # for creating anonymous type constraints
use Type::Params qw( compile ); # for parameter validation with Type::Tiny objects
use Types::Standard qw( :types ); # for basic type checking (Int Str etc.)
use Crypt::HSXKPasswd::Types qw( :types ); # for custom type checking
use Crypt::HSXKPasswd::Helper; # exports utility functions like _error & _warn
use Crypt::HSXKPasswd;
# 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)';
# 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)
lib/Crypt/HSXKPasswd/Util.pm view on Meta::CPAN
use strict;
use warnings;
use English qw( -no_match_vars ); # for more readable code
use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
use Readonly; # for truly constant constants
# HSXKPasswd stuff
use ${_MAIN_CLASS}::Helper;
# 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)';
#
# === Constants ===============================================================#
#
# version info
use version; our \$VERSION = qv('$version');
xscripts/generateDictionaries.pl view on Meta::CPAN
use warnings;
use English qw( -no_match_vars );
use Fatal qw( :void open close binmode ); # make builtins throw exceptions
use Readonly; # for truly constant constants
# HSXKPasswd Stuff
use lib './lib/';
use Crypt::HSXKPasswd::Util;
# 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)';
my $description = <<'ENDDESC';
#==============================================================================#
# Build The Bundled Dictionaries for Crypt::HSXKPasswd
#==============================================================================#
#
# This script is stored in xscripts, but designed to be run from the root of the