Class-Usul

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

    'Module::Build' => '0.4004',
    'version' => '0.88'
  },
  'recommends' => {
    'IPC::Run' => '0.89',
    'Proc::ProcessTable' => '0.42'
  },
  'requires' => {
    'Class::Inspector' => '1.28',
    'Class::Null' => '2.110730',
    'Crypt::CBC' => '2.33',
    'Crypt::Twofish2' => '1.02',
    'Data::Printer' => '0.36',
    'Data::Record' => '0.02',
    'Date::Format' => '2.24',
    'DateTime::Format::Epoch' => '0.16',
    'Exporter::Tiny' => '0.042',
    'File::DataClass' => 'v0.73.0',
    'File::Gettext' => 'v0.33.0',
    'File::HomeDir' => '1.0',
    'File::Which' => '1.18',

META.json  view on Meta::CPAN

         }
      },
      "runtime" : {
         "recommends" : {
            "IPC::Run" : "0.89",
            "Proc::ProcessTable" : "0.42"
         },
         "requires" : {
            "Class::Inspector" : "1.28",
            "Class::Null" : "2.110730",
            "Crypt::CBC" : "2.33",
            "Crypt::Twofish2" : "1.02",
            "Data::Printer" : "0.36",
            "Data::Record" : "0.02",
            "Date::Format" : "2.24",
            "DateTime::Format::Epoch" : "0.16",
            "Exporter::Tiny" : "0.042",
            "File::DataClass" : "v0.73.0",
            "File::Gettext" : "v0.33.0",
            "File::HomeDir" : "1.0",
            "File::Which" : "1.18",

META.yml  view on Meta::CPAN

    version: v0.84.1
  Class::Usul::Types:
    file: lib/Class/Usul/Types.pm
    version: v0.84.1
recommends:
  IPC::Run: '0.89'
  Proc::ProcessTable: '0.42'
requires:
  Class::Inspector: '1.28'
  Class::Null: '2.110730'
  Crypt::CBC: '2.33'
  Crypt::Twofish2: '1.02'
  Data::Printer: '0.36'
  Data::Record: '0.02'
  Date::Format: '2.24'
  DateTime::Format::Epoch: '0.16'
  Exporter::Tiny: '0.042'
  File::DataClass: v0.73.0
  File::Gettext: v0.33.0
  File::HomeDir: '1.0'
  File::Which: '1.18'

lib/Class/Usul/Crypt.pm  view on Meta::CPAN

package Class::Usul::Crypt;

use strict;
use warnings;

use Class::Usul::Constants qw( NUL );
use Class::Usul::Functions qw( create_token is_coderef is_hashref );
use Crypt::CBC;
use English                qw( -no_match_vars );
use Exporter 5.57          qw( import );
use MIME::Base64;
use Sys::Hostname;

our @EXPORT_OK = qw( cipher_list decrypt default_cipher encrypt );

my $DEFAULT = 'Twofish2'; my $SEED = do { local $RS = undef; <DATA> };

# Private functions

lib/Class/Usul/Crypt.pm  view on Meta::CPAN


my $_cipher_name = sub {
   (is_hashref $_[ 0 ]) ? $_[ 0 ]->{cipher} || $DEFAULT : $DEFAULT;
};

my $_compose = sub {
   $_eval->( $_dref->( $_[ 0 ]->{seed} ) || $SEED ).$_dref->( $_[ 0 ]->{salt} );
};

my $_new_crypt_cbc = sub {
   Crypt::CBC->new( -cipher => $_[ 0 ], -key => $_[ 1 ] );
};

my $_token = sub {
   create_token( $_compose->( $_[ 0 ] || {} ) );
};

my $_wards = sub {
   (is_hashref $_[ 0 ]) || !$_[ 0 ] ? $_token->( $_[ 0 ] ) : $_[ 0 ];
};

lib/Class/Usul/Crypt.pm  view on Meta::CPAN


The C<$key> can be a string (including the null string) or a hash reference
with I<salt> and I<seed> keys. The I<seed> attribute can be a code reference in
which case it will be called with no argument and the return value used

Lifted from L<Acme::Bleach> the default seed for the key generator has been
whitened and included in this source file

The seed is C<eval>'d in string context and then the salt is concatenated onto
it before being passed to L<create token|Class::Usul::Functions/create_token>.
Uses this value as the key for a L<Crypt::CBC> object

=head1 Subroutines/Methods

=head2 decrypt

   my $plain = decrypt( $salt || \%params, $encoded );

Decodes and decrypts the C<$encoded> argument and returns the plain
text result. See the L</encrypt> method

lib/Class/Usul/Crypt.pm  view on Meta::CPAN

   my $encoded = encrypt( $salt || \%params, $plain );

Encrypts the plain text passed in the C<$plain> argument and returns
it Base64 encoded. By default L<Crypt::Twofish2> is used to do the
encryption. The optional C<< $params->{cipher} >> attribute overrides this

=head2 cipher_list

   @list_of_ciphers = cipher_list();

Returns the list of ciphers supported by L<Crypt::CBC>. These may not
all be installed

=head2 default_cipher

   $ciper_name = default_cipher();

Returns I<Twofish2>

=head1 Diagnostics

None

=head1 Dependencies

=over 3

=item L<Crypt::CBC>

=item L<Crypt::Twofish2>

=item L<Exporter>

=item L<MIME::Base64>

=back

=head1 Incompatibilities

t/00report-metadata.dd  view on Meta::CPAN

                                      }
                      },
       'runtime' => {
                      'recommends' => {
                                        'IPC::Run' => '0.89',
                                        'Proc::ProcessTable' => '0.42'
                                      },
                      'requires' => {
                                      'Class::Inspector' => '1.28',
                                      'Class::Null' => '2.110730',
                                      'Crypt::CBC' => '2.33',
                                      'Crypt::Twofish2' => '1.02',
                                      'Data::Printer' => '0.36',
                                      'Data::Record' => '0.02',
                                      'Date::Format' => '2.24',
                                      'DateTime::Format::Epoch' => '0.16',
                                      'Exporter::Tiny' => '0.042',
                                      'File::DataClass' => 'v0.73.0',
                                      'File::Gettext' => 'v0.33.0',
                                      'File::HomeDir' => '1.0',
                                      'File::Which' => '1.18',

t/META.json  view on Meta::CPAN

         }
      },
      "runtime" : {
         "recommends" : {
            "IPC::Run" : "0.89",
            "Proc::ProcessTable" : "0.42"
         },
         "requires" : {
            "Class::Inspector" : "1.28",
            "Class::Null" : "2.101420",
            "Crypt::CBC" : "2.30",
            "Crypt::Twofish2" : "1.02",
            "Data::Printer" : "0.35",
            "Data::Record" : "0.02",
            "Date::Format" : "2.24",
            "DateTime::Format::Epoch" : "0.13",
            "Exporter::Tiny" : "0.026",
            "File::DataClass" : "v0.41.0",
            "File::Gettext" : "v0.23.0",
            "File::HomeDir" : "0.93",
            "Getopt::Long::Descriptive" : "0.093",



( run in 0.645 second using v1.01-cache-2.11-cpan-e1769b4cff6 )