view release on metacpan or search on metacpan
Notice/Notice.pm view on Meta::CPAN
's' => 1,
);
##################
sub check($$\{}) {
my($self,$p) = @_;
return () unless
exists $p->{expires} && $p->{expires} &&
$p->{expires} !~ /[^\d]/ && $p->{expires} > 0 &&
exists $p->{path} && $p->{path} && (-r $p->{path});
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Lite.pm view on Meta::CPAN
my $contentType = "";
my $priv = ""; # challenge key
my $debug = 0;
#----- FORWARD DECLARATIONS & PROTOTYPING
sub iso2hex($);
sub hex2iso($);
sub Error($);
sub Debug($);
sub new {
my $type = shift;
my %params = @_;
my $self = {};
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Lucifer.pm view on Meta::CPAN
$self;
}
sub set_key{
setkey($_[1]);
}
sub encrypt(){
return luc_encrypt($_[1]);
}
sub decrypt(){
return luc_decrypt($_[1]);
}
1;
__END__
=head1 NAME
view all matches for this distribution
view release on metacpan or search on metacpan
script/mk-ca-bundle.pl view on Meta::CPAN
print "Digest::SHA.pm Version : ${Digest::SHA::VERSION}\n" if ($Digest::SHA::VERSION);
print "Digest::SHA::PurePerl.pm Version : ${Digest::SHA::PurePerl::VERSION}\n" if ($Digest::SHA::PurePerl::VERSION);
print ("=" x 78 . "\n");
}
sub warning_message() {
if ( $opt_d =~ m/^risk$/i ) { # Long Form Warning and Exit
print "Warning: Use of this script may pose some risk:\n";
print "\n";
print " 1) Using http is subject to man in the middle attack of certdata content\n";
print " 2) Default to 'release', but more recent updates may be found in other trees\n";
script/mk-ca-bundle.pl view on Meta::CPAN
} else { # Short Form Warning
print "Warning: Use of this script may pose some risk, -d risk for more details.\n";
}
}
sub HELP_MESSAGE() {
print "Usage:\t${0} [-b] [-d<certdata>] [-f] [-i] [-l] [-n] [-p<purposes:levels>] [-q] [-s<algorithms>] [-t] [-u] [-v] [-w<l>] [<outputfile>]\n";
print "\t-b\tbackup an existing version of ca-bundle.crt\n";
print "\t-d\tspecify Mozilla tree to pull certdata.txt or custom URL\n";
print "\t\t Valid names are:\n";
print "\t\t ", join( ", ", map { ( $_ =~ m/$opt_d/ ) ? "$_ (default)" : "$_" } sort keys %urls ), "\n";
script/mk-ca-bundle.pl view on Meta::CPAN
print "\t-v\tbe verbose and print out processed CAs\n";
print "\t-w <l>\twrap base64 output lines after <l> chars (default: ${opt_w})\n";
exit;
}
sub VERSION_MESSAGE() {
print "${0} version ${version} running Perl ${]} on ${^O}\n";
}
warning_message() unless ($opt_q || $url =~ m/^(ht|f)tps:/i );
HELP_MESSAGE() if ($opt_h);
sub report($@) {
my $output = shift;
print STDERR $output . "\n" unless $opt_q;
}
sub is_in_list($@) {
my $target = shift;
return defined(List::Util::first { $target eq $_ } @_);
}
# Parses $param_string as a case insensitive comma separated list with optional whitespace
# validates that only allowed parameters are supplied
sub parse_csv_param($$@) {
my $description = shift;
my $param_string = shift;
my @valid_values = @_;
my @values = map {
script/mk-ca-bundle.pl view on Meta::CPAN
my @included_mozilla_trust_purposes = parse_csv_param( "trust purpose", $included_mozilla_trust_purposes_string, @valid_mozilla_trust_purposes );
my @included_mozilla_trust_levels = parse_csv_param( "trust level", $included_mozilla_trust_levels_string, @valid_mozilla_trust_levels );
my @included_signature_algorithms = parse_csv_param( "signature algorithm", $opt_s, @valid_signature_algorithms );
sub should_output_cert(%) {
my %trust_purposes_by_level = @_;
foreach my $level (@included_mozilla_trust_levels) {
# for each level we want to output, see if any of our desired purposes are included
return 1 if ( defined( List::Util::first { is_in_list( $_, @included_mozilla_trust_purposes ) } @{$trust_purposes_by_level{$level}} ) );
view all matches for this distribution
view release on metacpan or search on metacpan
@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK = qw( memfrob );
$VERSION = '1.00';
sub memfrob($) {
return(join("", map { chr((ord($_) ^ 42) + 0) } (split(//, shift))));
}
1;
__END__
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/MySQL.pm view on Meta::CPAN
require Exporter;
push @ISA, 'Exporter';
@EXPORT_OK = qw(password password41);
}
sub password41($) { "*".uc(sha1_hex(sha1($_[0]))); }
1;
__END__
=head1 NAME
view all matches for this distribution
view release on metacpan or search on metacpan
bin/Enigma.pl view on Meta::CPAN
use Crypt::OOEnigma;
#
# usage: display usage message
#
sub usage() {
print<<EOF;
usage: $0 [ options ] message
Options:
-h Displays this help message
view all matches for this distribution
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use 5.008008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
sub libOtrIsInstalled(){
if(-f('/usr/include/libotr/version.h')){
return 1;
} elsif (-f('/usr/local/include/libotr/version.h')){
return 1;
} else {
return 0;
}
}
sub libGcryptIsInstalled(){
if(-f('/usr/include/gcrypt.h')){
return 1;
} elsif (-f('/usr/local/include/gcrypt.h')){
return 1;
} else {
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Crypt/OpenSSL/CA/Test.pm view on Meta::CPAN
=back
=cut
sub _total_heap_size() {
require Devel::Mallinfo;
my $mallinfo = Devel::Mallinfo::mallinfo();
# From the perldoc of Devel::Mallinfo:
return $mallinfo->{uordblks}+$mallinfo->{usmblks}+$mallinfo->{hblkhd};
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/prime-field.t view on Meta::CPAN
SKIP: {
skip('OpenSSL does not support EC2M', 262) unless exists &Crypt::OpenSSL::EC::EC_GROUP::set_curve_GF2m;
&prime_field_tests();
};
sub prime_field_tests()
{
my $ctx = Crypt::OpenSSL::Bignum::CTX->new();
ok($ctx);
my $p = Crypt::OpenSSL::Bignum->new_from_hex('17');
view all matches for this distribution
view release on metacpan or search on metacpan
t/Crypt-OpenSSL-FASTPBKDF2.t view on Meta::CPAN
# This must match the number of main tests (subtests each count as main test)
my $number_of_tests = 1 + keys %{HMAC_SUBS()};
# Test against expected hmac_data
sub data_test($) {
my $hmac = shift;
my $test_sub = HMAC_SUBS()->{$hmac};
my $test_data = HMAC_DATA()->{$hmac};
subtest "HMAC $hmac"=>sub {
view all matches for this distribution
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use 5.008000;
use Config;
use ExtUtils::MakeMaker;
# have_inc() EV's Makefile.PL by Marc Lehmann <schmorp@schmorp.de>
sub have_inc($) {
scalar grep -r "$_/$_[0]", $Config{usrinc}, split / /, $Config{incpth}
}
my @LIBS;
my @DEFINES;
view all matches for this distribution
view release on metacpan or search on metacpan
##############################################################################
# Rhash class methods
# Rhash object constructor
sub new($$@)
{
my ($class, @hash_ids) = @_;
# validate @hash_ids to be an array of hash identifiers
scalar(@_) > 0 or die "hash_id not specified\n";
};
return bless $self, $class;
}
# destructor
sub DESTROY($)
{
my $self = shift;
# the 'if' added as workaround for perl 'global destruction' bug
# ($self->{context} can disappear on global destruction)
rhash_free($self->{context}) if $self->{context};
}
sub update($$)
{
my $self = shift;
my $message = shift;
rhash_update($self->{context}, $message);
return $self;
}
sub update_fd($$;$$)
{
my ($self, $fd, $start, $size) = @_;
my $res = 0;
my $num = 0;
}
return (defined($res) ? $num : undef); # return undef on read error
}
sub update_file($$;$$)
{
my ($self, $file, $start, $size) = @_;
open(my $fd, "<", $file) or return undef;
my $res = $self->update_fd($fd, $start, $size);
close($fd);
return $res;
}
sub final($)
{
my $self = shift;
rhash_final($self->{context});
return $self;
}
sub reset($)
{
my $self = shift;
rhash_reset($self->{context});
return $self;
}
sub hashed_length($)
{
my $self = shift;
return rhash_get_hashed_length($self->{context});
}
sub hash_id($)
{
my $self = shift;
return rhash_get_hash_id($self->{context});
}
use constant RHPR_BASE32 => 0x3;
use constant RHPR_BASE64 => 0x4;
use constant RHPR_UPPERCASE => 0x8;
use constant RHPR_REVERSE => 0x10;
sub hash($;$$)
{
my $self = shift;
my $hash_id = scalar(shift) || 0;
my $print_flags = scalar(shift) || RHPR_DEFAULT;
return rhash_print_wrapper($self->{context}, $hash_id, $print_flags);
}
sub hash_base32($;$)
{
hash($_[0], $_[1], RHPR_BASE32);
}
sub hash_base64($;$)
{
hash($_[0], $_[1], RHPR_BASE64);
}
sub hash_hex($;$)
{
hash($_[0], $_[1], RHPR_HEX);
}
sub hash_rhex($;$)
{
hash($_[0], $_[1], RHPR_HEX | RHPR_REVERSE);
}
sub hash_raw($;$)
{
hash($_[0], $_[1], RHPR_RAW);
}
sub magnet_link($;$@)
{
my ($self, $filename, @hash_ids) = @_;
my $hash_mask = 0;
if (scalar(@hash_ids)) {
for my $id (@hash_ids) {
die "the method $field() $text in the class $pkg\n";
}
# static functions
sub msg($$)
{
my ($hash_id, $msg) = @_;
my $raw = rhash_msg_wrapper($hash_id, $msg); # get a binary message digest
return (is_base32($hash_id) ? raw2base32($raw) : raw2hex($raw));
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/RandPasswd.pm view on Meta::CPAN
=head1 Functions
=cut
sub word($$);
sub letters($$);
sub chars($$);
sub random_chars_in_range($$$$);
sub rand_int_in_range($$);
sub random_element($);
sub rng($);
sub restrict($);
sub init();
sub _random_word($);
sub _random_unit($);
sub _improper_word(@);
sub _have_initial_y(@);
sub _have_final_split(@);
sub _illegal_placement(@);
#
# Global Variables:
#
lib/Crypt/RandPasswd.pm view on Meta::CPAN
# } END DIGRAM
##############################################################################################
sub report(@) {
$main::DEBUG and print @_;
}
lib/Crypt/RandPasswd.pm view on Meta::CPAN
Generates a random word, as well as its hyphenated form.
The length of the returned word will be between minlen and maxlen.
=cut
sub word($$) {
@_ > 2 and shift;
my( $minlen, $maxlen ) = @_;
$minlen <= $maxlen or die "minlen $minlen is greater than maxlen $maxlen";
lib/Crypt/RandPasswd.pm view on Meta::CPAN
The length of the returned word is between minlen and maxlen.
Calls C<random_chars_in_range( 'a' =E<gt> 'z' )>.
=cut
sub letters($$) {
@_ > 2 and shift;
my( $minlen, $maxlen ) = @_;
random_chars_in_range( $minlen, $maxlen, 'a' => 'z' ); # range of lowercase letters in ASCII
}
lib/Crypt/RandPasswd.pm view on Meta::CPAN
The length of the returned word is between minlen and maxlen.
Calls C<random_chars_in_range( '!' =E<gt> '~' )>.
=cut
sub chars($$) {
@_ > 2 and shift;
my( $minlen, $maxlen ) = @_;
random_chars_in_range( $minlen, $maxlen, '!' => '~' ); # range of printable chars in ASCII
}
lib/Crypt/RandPasswd.pm view on Meta::CPAN
Each character is selected from the range of ASCII characters
delimited by (lo_char,hi_char).
=cut
sub random_chars_in_range($$$$) {
my( $minlen, $maxlen, $lo_char, $hi_char ) = @_;
$minlen <= $maxlen or die "minlen $minlen is greater than maxlen $maxlen";
init();
lib/Crypt/RandPasswd.pm view on Meta::CPAN
n = min + int( rng( max - min + 1 ) )
=cut
sub rand_int_in_range($$) {
my( $min, $max ) = @_;
$min + int( rng( $max - $min + 1 ) )
}
lib/Crypt/RandPasswd.pm view on Meta::CPAN
Selects a random element from an array, which is passed by ref.
=cut
sub random_element($) {
my $ar = shift;
$ar->[ rand_int_in_range( 0, $#{$ar} ) ]
}
lib/Crypt/RandPasswd.pm view on Meta::CPAN
See L<rand>.
=cut
sub rng($) {
my $x = shift;
rand($x)
}
lib/Crypt/RandPasswd.pm view on Meta::CPAN
*Crypt::RandPasswd::restrict = \&my_filter;
}
=cut
sub restrict($) { $_[0] } # MUST return a real scalar; returning @_ causes scalar(@_) !!!
=head2 init
This initializes the environment, which by default simply seeds the random number generator.
lib/Crypt/RandPasswd.pm view on Meta::CPAN
=cut
# can be called multiple times without harm, since it remembers whether
# it has already been called.
sub init() {
unless ( $Crypt::RandPasswd::initialized ) {
# only do stuff if I haven't already been called before.
$Crypt::RandPasswd::initialized = 1;
if ( defined $Crypt::RandPasswd::seed ) {
lib/Crypt/RandPasswd.pm view on Meta::CPAN
# If a retry threshold is reached, another word is tried.
#
# returns ( word, hyphenated_word ).
#
sub _random_word($) {
my( $pwlen ) = @_;
my $word = '';
my @word_syllables;
lib/Crypt/RandPasswd.pm view on Meta::CPAN
( ($_) x $occurrence_frequencies{$_} )
} @vowel_grams;
sub _random_unit($) {
my $type = shift; # byte
random_element( $type & VOWEL
? \@vowel_numbers # Sometimes, we are asked to explicitly get a vowel (i.e., if
# a digram pair expects one following it). This is a shortcut
lib/Crypt/RandPasswd.pm view on Meta::CPAN
# the length of 6 at most.
#
# returns boolean
#
sub _improper_word(@) {
my @units = @_;
my $failure; # bool, init False.
for my $unit_count ( 0 .. $#units ) {
lib/Crypt/RandPasswd.pm view on Meta::CPAN
# The word ycl is one example. We discard words like these.
#
# return boolean
#
sub _have_initial_y(@) {
my @units = @_;
my $vowel_count = 0;
my $normal_vowel_count = 0;
lib/Crypt/RandPasswd.pm view on Meta::CPAN
# be generated.
#
# returns boolean
#
sub _have_final_split(@) {
my @units = @_;
my $vowel_count = 0;
#
lib/Crypt/RandPasswd.pm view on Meta::CPAN
# global (like a C static)
use vars qw( @saved_pair );
@saved_pair = (); # 0..2 elements, which are units (grams).
sub get_syllable($) {
my $pwlen = shift;
# these used to be "out" params:
my $syllable; # string, returned
my @units_in_syllable = (); # array of units, returned
lib/Crypt/RandPasswd.pm view on Meta::CPAN
#
# I<This is an alternative version of C<get_syllable()>, which
# can be useful for unit testing the other functions.>
#
sub alt_get_syllable($) { # alternative version, has no smarts.
my $pwlen = shift; # max or min?
for ( 0 .. $#grams ) {
my $syl = '';
my @syl_units = ();
while ( @syl_units < 3 ) {
lib/Crypt/RandPasswd.pm view on Meta::CPAN
# (unless one of them is the final silent e).
#
# returns boolean.
#
sub _illegal_placement(@) {
my @units = @_;
my $vowel_count = 0;
my $failure = 0; # false
view all matches for this distribution
view release on metacpan or search on metacpan
##############################################################################
# Rhash class methods
# Rhash object constructor
sub new($$@)
{
my $hash_id = 0;
shift;
scalar(@_) > 0 or die "hash_id not specified";
for my $id (@_) {
};
return bless $self;
}
# destructor
sub DESTROY($)
{
my $self = shift;
# the 'if' added as workaround for perl 'global destruction' bug
# ($self->{context} can disappear on global destruction)
rhash_free($self->{context}) if $self->{context};
}
sub update($$)
{
my $self = shift;
my $message = shift;
rhash_update($self->{context}, $message);
return $self;
}
sub update_fd($$;$$)
{
my ($self, $fd, $start, $size) = @_;
my $res = 0;
my $num = 0;
}
return (defined($res) ? $num : undef); # return undef on read error
}
sub update_file($$;$$)
{
my ($self, $file, $start, $size) = @_;
open(my $fd, "<", $file) or return undef;
my $res = $self->update_fd($fd, $start, $size);
close($fd);
return $res;
}
sub final($)
{
my $self = shift;
rhash_final($self->{context});
return $self;
}
sub reset($)
{
my $self = shift;
rhash_reset($self->{context});
return $self;
}
sub hashed_length($)
{
my $self = shift;
return rhash_get_hashed_length($self->{context});
}
sub hash_id($)
{
my $self = shift;
return rhash_get_hash_id($self->{context});
}
use constant RHPR_BASE32 => 0x3;
use constant RHPR_BASE64 => 0x4;
use constant RHPR_UPPERCASE => 0x8;
use constant RHPR_REVERSE => 0x10;
sub hash($;$$)
{
my $self = shift;
my $hash_id = scalar(shift) || 0;
my $print_flags = scalar(shift) || RHPR_DEFAULT;
return rhash_print($self->{context}, $hash_id, $print_flags);
}
sub hash_base32($;$)
{
hash($_[0], $_[1], RHPR_BASE32);
}
sub hash_base64($;$)
{
hash($_[0], $_[1], RHPR_BASE64);
}
sub hash_hex($;$)
{
hash($_[0], $_[1], RHPR_HEX);
}
sub hash_rhex($;$)
{
hash($_[0], $_[1], RHPR_HEX | RHPR_REVERSE);
}
sub hash_raw($;$)
{
hash($_[0], $_[1], RHPR_RAW);
}
sub magnet_link($;$$)
{
my ($self, $filename, $hash_mask) = @_;
return rhash_print_magnet($self->{context}, $filename, $hash_mask);
}
die "the method $field() $text in the class $pkg";
}
# static functions
sub msg($$)
{
my ($hash_id, $msg) = @_;
my $raw = rhash_msg_raw($hash_id, $msg); # get binary hash
return (is_base32($hash_id) ? raw2base32($raw) : raw2hex($raw));
}
view all matches for this distribution
view release on metacpan or search on metacpan
Rijndael_PP.pm view on Meta::CPAN
# alg-ref.h
# define MAXBC (256/32)
# define MAXKC (256/32)
# define MAXROUNDS 14
sub MAXBC() { 8 }
sub MAXKC() { 8 }
sub MAXROUNDS() { 14 }
# alg-ref.c
use constant shifts => [
[[0, 0], [1, 3], [2, 2], [3, 1]],
Rijndael_PP.pm view on Meta::CPAN
# * needed for MixColumn and InvMixColumn
# */
# if (a && b) return Alogtable[(Logtable[a] + Logtable[b])%255];
# else return 0;
#}
sub mul($$) {
$_[0] && $_[1] ? Algotable->[(Logtable->[$_[0]] + Logtable->[$_[1]]) % 255] : 0
}
#void KeyAddition(word8 a[4][MAXBC], word8 rk[4][MAXBC], word8 BC) {
# /* Exor corresponding text input and round key input bytes
Rijndael_PP.pm view on Meta::CPAN
# for $j (0..$BC-1) { $a[$i][$j] = $tmp[$j] }
# }
# @_[0..3] = @a; # return by reference
#}
sub ShiftRow(@) {
my @tmp;
for my $i (1..3) {
my $j;
for $j (0..$_[5]-1) { $tmp[$j] = $_[$i][($j + shifts->[($_[5]-4)>>1][$i][$_[4]]) % $_[5]] }
for $j (0..$_[5]-1) { $_[$i][$j] = $tmp[$j] }
Rijndael_PP.pm view on Meta::CPAN
##################################
# api-ref.c
# define DIR_ENCRYPT 0 /* Are we encrpyting? */
sub DIR_ENCRYPT() { 0 }
# define DIR_DECRYPT 1 /* Are we decrpyting? */
sub DIR_DECRYPT() { 1 }
# define MODE_ECB 1 /* Are we ciphering in ECB mode? */
sub MODE_ECB() { 1 }
# define MODE_CBC 2 /* Are we ciphering in CBC mode? */
sub MODE_CBC() { 2 }
# define MODE_CFB1 3 /* Are we ciphering in 1-bit CFB mode? */
sub MODE_CFB1() { 3 }
# define TRUE 1
sub TRUE() { 1 }
# define FALSE 0
sub FALSE() { 0 }
# define BITSPERBLOCK 128 /* Default number of bits in a cipher block */
sub BITSPERBLOCK() { 128 }
# /* Error Codes - CHANGE POSSIBLE: inclusion of additional error codes */
#define BAD_KEY_DIR -1 /* Key direction is invalid, e.g., unknown value */
#define BAD_KEY_MAT -2 /* Key material not of correct length */
#define BAD_KEY_INSTANCE -3 /* Key passed is not valid */
Rijndael_PP.pm view on Meta::CPAN
#define BAD_CIPHER_STATE -5 /* Cipher in wrong state (e.g., not initialized) */
#define BAD_CIPHER_INSTANCE -7
# /* CHANGE POSSIBLE: inclusion of algorithm specific defines */
#define MAX_KEY_SIZE 64 /* # of ASCII char's needed to represent a key */
sub MAX_KEY_SIZE() { 64 }
#define MAX_IV_SIZE BITSPERBLOCK/8 /* # bytes needed to represent an IV */
sub MAX_IV_SIZE() { BITSPERBLOCK/8 }
#int makeKey(keyInstance *key, BYTE direction, int keyLen, char *keyMaterial)
#{
# word8 k[4][MAXKC];
# int i, j, t;
sub makeKey($$$$) {
my ($key, $direction, $keyLen, $keyMaterial) = @_;
#$keyLen = length $keyMaterial; # hey, it's perl :-)
Rijndael_PP.pm view on Meta::CPAN
#int cipherInit(cipherInstance *cipher, BYTE mode, char *IV)
#{
# int i, j, t;
sub cipherInit($$;$) {
my ($cipher, $mode, $IV) = @_;
my $i;
Rijndael_PP.pm view on Meta::CPAN
# keyInstance *key, BYTE *input, int inputLen, BYTE *outBuffer)
#{
# int i, j, t, numBlocks;
# word8 block[4][MAXBC];
sub blockEncrypt($$$$$) {
my ($cipher, $key, $input, $inputLen, $outBuffer) = @_;
my ($i,$j,$t,$numBlocks,@block);
Rijndael_PP.pm view on Meta::CPAN
# keyInstance *key, BYTE *input, int inputLen, BYTE *outBuffer)
#{
# int i, j, t, numBlocks;
# word8 block[4][MAXBC];
sub blockDecrypt($$$$$) {
my ($cipher, $key, $input, $inputLen, $outBuffer) = @_;
my ($i,$j,$t,$numBlocks,@block);
Rijndael_PP.pm view on Meta::CPAN
# */
#int cipherUpdateRounds(cipherInstance *cipher,
# keyInstance *key, BYTE *input, int inputLen, BYTE *outBuffer, int rounds)
#{
sub cipherUpdateRounds($$$$$$) {
my ($cipher, $key, $input, $inputLen, $outBuffer, $rounds) = @_;
# int j, t;
# word8 block[4][MAXBC];
Rijndael_PP.pm view on Meta::CPAN
return unless defined $out;
$out;
}
sub rijndael_encrypt($$$;$$) {
my ($key, $mode, $data, $keysize, $blocksize) = @_;
$keysize = 128 unless defined $keysize;
$blocksize = 128 unless defined $blocksize;
Rijndael_PP.pm view on Meta::CPAN
$out;
}
sub rijndael_decrypt($$$;$$) {
my ($key, $mode, $data, $keysize, $blocksize) = @_;
$keysize = 128 unless defined $keysize;
$blocksize = 128 unless defined $blocksize;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/SMimeEngine.pm view on Meta::CPAN
# COSTRUTTORE
# IN: opz. boolean - true nessun log, false altrimenti
# OUT: rif. oggetto se ok, stringa d'errore
# altrimenti
#
sub init($$$$$;$) {
my $cert_dir = shift;
my $cert = shift;
my $key = shift;
my $other_cert= shift;
my $engine = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/SSSS.pm view on Meta::CPAN
use POSIX qw(ceil pow);
use Crypt::SSSS::Message;
require Carp;
sub ssss_distribute(%) {
my (%data) = @_;
my $message = $data{message} or Carp::croak 'Missed "message" argument';
my $k = $data{k} or Carp::croak 'Missed "k" argument';
lib/Crypt/SSSS.pm view on Meta::CPAN
}
$shares;
}
sub ssss_reconstruct(%) {
my (%data) = @_;
my $shares = $data{shares};
my $p = $data{p} || '257';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
the message to the given address.
=cut
sub SendMail(){
my $self = shift;
my ($from,$to,$subject,$message) = @_;
my $rtn = 1;
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
Cleans up after the module by deleting temporary files.
=cut
sub Close(){
my $self = shift;
if ( -f $self->{tmp_cert_file} ) {
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
$self->{sendmail_path} = '/usr/lib/sendmail';
}
}
sub _assessor_util(){
my $self = shift;
my ($value,$key) = @_;
if ($value) {
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
If a the open sll binary path is passed, this accessor will set the value.
It will always return the value stored.
=cut
sub OpenSSLPath(){
my $self = shift;
my ($var) = @_;
return $self->_assessor_util($var,'open_ssl_path');
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
If a the sendmail binary path is passed, this accessor will set the value.
It will always return the value stored.
=cut
sub SendmailPath(){
my $self = shift;
my ($var) = @_;
return $self->_assessor_util($var,'sendmail_path');
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
It will always return the value stored.
=cut
sub CertificatePath(){
my $self = shift;
my ($var) = @_;
return $self->_assessor_util($var,'certificate_path');
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
pass the contents this routine.
=cut
sub SignedEmailCertificate(){
my $self = shift;
my ($var) = @_;
if ($var) {
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
Accepts the certificate contents from a variable to use to encrypt the message.
=cut
sub Certificate(){
my $self = shift;
my ($var) = @_;
if ($var) {
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
Returns true if the module encountered an error.
=cut
sub Error(){
my $self = shift;
my ($var) = @_;
return $self->_assessor_util($var,'error_message');
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
Returns the error message module encountered an error.
=cut
sub ErrorMessage(){
my $self = shift;
my ($var) = @_;
return $self->_assessor_util($var,'error_message');
lib/Crypt/Simple/SMIME.pm view on Meta::CPAN
Returns the command used to encrypt the email.
=cut
sub EncryptCommand(){
my $self = shift;
my ($var) = @_;
return $self->_assessor_util($var,'encrypt_command');
view all matches for this distribution
view release on metacpan or search on metacpan
use Compress::Zlib;
use MIME::Base64;
use Digest::MD5 qw(md5);
use FreezeThaw qw(freeze thaw);
sub _chunk($) { $_[0] =~ /.{1,8}/ogs }
sub import {
my ($class, @args) = @_;
my $caller = caller;
my $key = $class->get_key_param(@args)
view all matches for this distribution
view release on metacpan or search on metacpan
# lmhash PASSWORD
# Generates lanman password hash for a given password, returns the hash
#
# Extracted and ported from SAMBA/source/libsmb/smbencrypt.c:nt_lm_owf_gen
sub lmhash($;$) {
my ( $pass, $pwenc ) = @_;
my ( @p16 );
$pass = "" unless defined($pass);
$pass = uc($pass);
# nthash PASSWORD
# Generates nt md4 password hash for a given password, returns the hash
#
# Extracted and ported from SAMBA/source/libsmb/smbencrypt.c:nt_lm_owf_gen
sub nthash($) {
my ( $pass ) = @_;
my ( $hex );
my ( $digest );
$pass = substr(defined($pass)?$pass:"",0,128);
if (!$HaveUnicode) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/URandom/MonkeyPatch.pm view on Meta::CPAN
BEGIN {
*CORE::GLOBAL::rand = \&rand;
}
sub rand(;$) {
my $a = shift || 1;
my ($b) = unpack( "N", urandom(4) ) & MASK;
if ( $ENV{CRYPT_URANDOM_MONKEYPATCH_DEBUG} ) {
my ( $package, $filename, $line ) = caller;
say STDERR __PACKAGE__ . "::urandom used from ${package} line ${line}";
view all matches for this distribution
view release on metacpan or search on metacpan
UnixCrypt.pm view on Meta::CPAN
$out[0] = $left; $out[1] = $right;
return \@out;
}
sub crypt($$) # String crypt(String plaintext, String salt)
{
my ($plaintext, $salt) = @_;
my $buffer = '';
return $buffer if !defined $salt || $salt eq '';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/XKCDCommon1949.pm view on Meta::CPAN
"year","yellow","yes","yesterday","yet","you","young","younger",
"your","yourself","youth","zero","zoo"
);
push @EXPORT_OK, '@'.'words';
sub xkcd_common_1949() { return @words }
push @EXPORT_OK, 'xkcd_common_1949';
1;
__END__
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Crypt/Misc.pm view on Meta::CPAN
$diff |= ord(substr $a, $i) ^ ord(substr $b, $i);
}
return $diff == 0;
}
sub random_v4uuid() {
# Version 4 - random - UUID: xxxxxxxx-xxxx-4xxx-Yxxx-xxxxxxxxxxxx
# where x is any hexadecimal digit and Y is one of 8, 9, A, B (1000, 1001, 1010, 1011)
# e.g. f47ac10b-58cc-4372-a567-0e02b2c3d479
my $raw = random_bytes(16);
# xxxxxxxxxxxx4xxxYxxxxxxxxxxxxxxx
lib/Crypt/Misc.pm view on Meta::CPAN
my $hex = unpack("H*", $raw);
$hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12}).*$/$1-$2-$3-$4-$5/;
return $hex;
}
sub is_v4uuid($) {
my $uuid = shift;
return 0 if !$uuid;
return 1 if $uuid =~ /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
return 0;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Curses/UI/AnyEvent.pm view on Meta::CPAN
$self->Curses::UI::Common::char_read(0); ## Ignore timeout passed in to us, hard-code to 0
}
sub tempdialog() {
my $self = shift;
my $class = shift;
my %args = @_;
my $cb = delete $args{-cb} || sub {};
view all matches for this distribution
view release on metacpan or search on metacpan
examples/grid-demo.pl view on Meta::CPAN
# ----------------------------------------------------------------------
# Setup bindings and focus
# ----------------------------------------------------------------------
sub goto_next_demo()
{
$current_demo++;
$current_demo = 3 if $current_demo > 3;
$w{$current_demo}->focus;
}
sub goto_prev_demo()
{
$current_demo--;
$current_demo = 1 if $current_demo < 1;
$w{$current_demo}->focus;
}
examples/grid-demo.pl view on Meta::CPAN
sub select_demo($;)
{
my $nr = shift;
$current_demo = $nr;
$w{$current_demo}->focus;
}
sub fill_data($;) {
my $offset=shift;
my $limit=shift;
my $data=shift;
my $grid=shift;
view all matches for this distribution
view release on metacpan or search on metacpan
examples/color_editor view on Meta::CPAN
# ----------------------------------------------------------------------
# Callback routines
# ----------------------------------------------------------------------
sub open_dialog()
{
my $file = $cui->loadfilebrowser(
-file => $currentfile,
-bg => "green",
-fg => "white",
examples/color_editor view on Meta::CPAN
$cui->error(-message => "Can't read file \"$file\":\n$!");
}
}
}
sub save_dialog()
{
my $file = $cui->savefilebrowser(
-file => $currentfile,
-bg => "green",
examples/color_editor view on Meta::CPAN
} else {
$cui->error(-message => "Can't write to $file:\n$!");
}
}
sub about_dialog()
{
$cui->dialog(
-title => 'About editor',
-message => "Program : Curses::UI::POE Editor\n"
. "Author : Maurice Makaay\n"
examples/color_editor view on Meta::CPAN
-tbg => "white",
-tfg => "red",
);
}
sub exit_dialog()
{
my $return = $cui->dialog(
-title => "Are you sure???",
-buttons => ['yes', 'no'],
-message => "Do you really want to quit?",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Curses/UI.pm view on Meta::CPAN
$Curses::UI::initialized = 1;
return $self;
}
sub layout_new()
{
my $self = shift;
$Curses::UI::screen_too_small = 0;
lib/Curses/UI.pm view on Meta::CPAN
# Event handling
# ----------------------------------------------------------------------
# TODO: document
sub do_one_event(;$)
{
my $self = shift;
my $object = shift;
$object = $self unless defined $object;
lib/Curses/UI.pm view on Meta::CPAN
}
# TODO: document
# TODO: document
sub add_callback()
{
my $self = shift;
my $id = shift;
my $code = shift;
lib/Curses/UI.pm view on Meta::CPAN
$self->{-added_code}->{$id} = $code;
}
# TODO: document
sub delete_callback()
{
my $self = shift;
my $id = shift;
$self->fatalerror(
lib/Curses/UI.pm view on Meta::CPAN
delete $self->{-added_code}->{$id} if
defined $self->{-added_code}->{$id};
}
sub draw()
{
my $self = shift;
my $no_doupdate = shift || 0;
if ($Curses::UI::screen_too_small)
lib/Curses/UI.pm view on Meta::CPAN
doupdate() unless $no_doupdate;
}
}
# TODO: document
sub feedkey()
{
my $self = shift;
my $key = shift;
$self->{-feedkey} = $key;
return $self;
}
# TODO: document
sub flushkeys()
{
my $self = shift;
my $key = '';
my @k = ();
lib/Curses/UI.pm view on Meta::CPAN
}
}
# Returns 0 if less than -keydelay seconds have elapsed since the last
# user action. Returns the number of elapsed seconds otherwise.
sub keydelay()
{
my $self = shift;
my $time = time();
my $elapsed = $time - $self->{-lastkey};
lib/Curses/UI.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# Timed event handling
# ----------------------------------------------------------------------
sub set_read_timeout()
{
my $self = shift;
my $new_timeout = -1;
TIMER: while (my ($id, $config) = each %{$self->{-timers}})
lib/Curses/UI.pm view on Meta::CPAN
$self->{-read_timeout} = $new_timeout;
return $self;
}
sub set_timer($$;)
{
my $self = shift;
my $id = shift;
my $callback = shift;
my $time = shift || 1;
lib/Curses/UI.pm view on Meta::CPAN
$self->set_read_timeout;
return $self;
}
sub disable_timer($;)
{
my ($self,$id) = @_;
if (defined $self->{-timers}->{$id}) {
$self->{-timers}->{$id}->{-enabled} = 0;
}
$self->set_read_timeout;
return $self;
}
sub enable_timer($;)
{
my ($self,$id) = @_;
if (defined $self->{-timers}->{$id}) {
$self->{-timers}->{$id}->{-enabled} = 1;
}
$self->set_read_timeout;
return $self;
}
sub delete_timer($;)
{
my ($self,$id) = @_;
if (defined $self->{-timers}->{$id}) {
delete $self->{-timers}->{$id};
}
$self->set_read_timeout;
return $self;
}
sub do_timer()
{
my $self = shift;
my $now = time();
my $timers_done = 0;
lib/Curses/UI.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# Mouse events
# ----------------------------------------------------------------------
sub handle_mouse_event()
{
my $self = shift;
my $object = shift;
$object = $self unless defined $object;
lib/Curses/UI.pm view on Meta::CPAN
my $return = $object->event_mouse(\%MEVENT);
last if defined $return and $return ne 'DELEGATE';
}
}
sub handle_gpm_mouse_event()
{
my $self = shift;
my $object = shift;
$object = $self unless defined $object;
lib/Curses/UI.pm view on Meta::CPAN
last if defined $return and $return ne 'DELEGATE';
}
}
sub object_at_xy($$;$)
{
my $self = shift;
my $object = shift;
my $x = shift;
my $y = shift;
lib/Curses/UI.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# Other subroutines
# ----------------------------------------------------------------------
# TODO: document
sub fatalerror($$;$)
{
my $self = shift;
my $error = shift;
my $exit = shift;
lib/Curses/UI.pm view on Meta::CPAN
}
exit($exit);
}
sub usemodule($;)
{
my $self = shift;
my $class = shift;
# Create class filename.
lib/Curses/UI.pm view on Meta::CPAN
}
return $self;
}
sub focus_path()
{
my $self = shift;
my $index = shift;
my $p_obj = $self;
lib/Curses/UI.pm view on Meta::CPAN
# add() is overridden, because we only want to be able
# to add Curses::UI:Window objects to the Curses::UI
# rootlevel.
#
sub add()
{
my $self = shift;
my $id = shift;
my $class = shift;
my %args = @_;
lib/Curses/UI.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# Focusable dialog windows
# ----------------------------------------------------------------------
sub tempdialog()
{
my $self = shift;
my $class = shift;
my %args = @_;
lib/Curses/UI.pm view on Meta::CPAN
#
# instead of:
#
# $cui->dialog(-message => "Some dialog message");
#
sub process_args()
{
my $self = shift;
my $ifone = shift;
if (@_ == 1) { @_ = ($ifone => $_[0]) }
return @_;
}
sub error()
{
my $self = shift;
my %args = $self->process_args('-message', @_);
$self->tempdialog('Dialog::Error', %args);
}
sub dialog()
{
my $self = shift;
my %args = $self->process_args('-message', @_);
$self->tempdialog('Dialog::Basic', %args);
}
sub question()
{
my $self = shift;
my %args = $self->process_args('-question', @_);
$self->tempdialog('Dialog::Question', %args);
}
sub calendardialog()
{
my $self = shift;
my %args = $self->process_args('-title', @_);
$self->tempdialog('Dialog::Calendar', %args);
}
sub filebrowser()
{
my $self = shift;
my %args = $self->process_args('-title', @_);
# Create title
lib/Curses/UI.pm view on Meta::CPAN
# Select a file to load from.
$self->tempdialog('Dialog::Filebrowser', %args);
}
sub dirbrowser()
{
my $self = shift;
my %args = $self->process_args('-title', @_);
# Create title
lib/Curses/UI.pm view on Meta::CPAN
# Select a file to load from.
$self->tempdialog('Dialog::Dirbrowser', %args);
}
sub savefilebrowser()
{
my $self = shift;
my %args = $self->process_args('-title', @_);
my $l = $self->root->lang;
lib/Curses/UI.pm view on Meta::CPAN
}
return $file;
}
sub loadfilebrowser()
{
my $self = shift;
my %args = $self->process_args('-title', @_);
# Create title
lib/Curses/UI.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# Non-focusable dialogs
# ----------------------------------------------------------------------
my $status_id = "__status_dialog";
sub status($;)
{
my $self = shift;
my %args = $self->process_args('-message', @_);
$self->delete($status_id);
$self->add($status_id, 'Dialog::Status', %args)->draw;
return $self;
}
sub nostatus()
{
my $self = shift;
$self->delete($status_id);
$self->flushkeys();
$self->draw;
return $self;
}
sub progress()
{
my $self = shift;
my %args = @_;
$self->add(
lib/Curses/UI.pm view on Meta::CPAN
$self->draw;
return $self;
}
sub setprogress($;$)
{
my $self = shift;
my $pos = shift;
my $message = shift;
lib/Curses/UI.pm view on Meta::CPAN
$p->draw;
return $self;
}
sub noprogress()
{
my $self = shift;
$self->delete("__progress_$self");
$self->flushkeys;
$self->draw;
return $self;
}
sub leave_curses()
{
my $self = shift;
def_prog_mode();
endwin();
}
sub reset_curses()
{
my $self = shift;
reset_prog_mode();
$self->layout(); # In case the terminal has been resized
}
### Color support
sub color() {
my $self = shift;
return $Curses::UI::color_object;
}
sub set_color {
lib/Curses/UI.pm view on Meta::CPAN
# ----------------------------------------------------------------------
# Accessor functions
# ----------------------------------------------------------------------
sub compat(;$) { shift()->accessor('-compat', shift()) }
sub clear_on_exit(;$) { shift()->accessor('-clear_on_exit', shift()) }
sub cursor_mode(;$) { shift()->accessor('-cursor_mode', shift()) }
sub lang(;$) { shift()->accessor('-language_object', shift()) }
sub overlapping(;$) { shift()->accessor('-overlapping', shift()) }
# TODO: document
sub debug(;$)
{
my $self = shift;
my $value = shift;
$Curses::UI::debug = $self->accessor('-debug', $value);
}
view all matches for this distribution
view release on metacpan or search on metacpan
"No '$N' in Curses module. This could be because the Curses " .
"library for which it was built does not provide the associated " .
"functions. ";
}
sub printw($@) {
my ($format, @substitutions) = @_;
addstring(sprintf($format, @substitutions));
}
view all matches for this distribution