Crypt-Camellia_PP

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Changes
lib/Crypt/Camellia_PP.pm
Makefile.PL
MANIFEST
README
TODO
t/00-basic.t
t/01-CBC.t
t/02-test-vectors-simple.t
t/03-test-vectors-full.t
META.yml                                 Module meta-data (added by MakeMaker)

META.yml  view on Meta::CPAN

# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
name:         Crypt-Camellia_PP
version:      0.02
version_from: lib/Crypt/Camellia_PP.pm
installdirs:  site
requires:
    Crypt::CBC:                    2.13

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17

Makefile.PL  view on Meta::CPAN

use 5.008006;
use ExtUtils::MakeMaker;
WriteMakefile(
    NAME              => 'Crypt::Camellia_PP',
    VERSION_FROM      => 'lib/Crypt/Camellia_PP.pm',
    PREREQ_PM         => {
        'Crypt::CBC' => 2.13,
    },
    ($] >= 5.005 ?
      (ABSTRACT_FROM  => 'lib/Crypt/Camellia_PP.pm', # retrieve abstract from module
       AUTHOR         => 'Hiroyuki OYAMA <oyama@module.jp>') : ()),
);

lib/Crypt/Camellia_PP.pm  view on Meta::CPAN

  use Crypt::Camellia_PP;
  
  my $key = pack 'H*', '00112233445566778899AABBCCDDEEFF';
  my $src = pack 'H*', 'FFEEDDCCBBAA99887766554433221100';
  my $camellia = Crypt::Camellia_PP->new($key);
  my $cipher_string = $camellia->encrypt($src);
  
  my $plain_string = $camellia->decrypt($cipher_string);
  $plain_string eq $src;

=head2 With Crypt::CBC module

  use Crypt::CBC;
  
  my $cbc = Crypt::CBC->new({
      cipher => 'Crypt::Camellia_PP',
      key => pack('H*', '00112233445566778899aabbccddeeff'),
      iv  => pack('H*', '00000000000000000000000000000000'),
      literal_key => 1,
      header => 'none',
      padding => 'standard',
  });
  my $cipher_text = $cbc->encrypt('Hello World!');
  my $plain_text = $cbc->decrypt($cipher_text);
  $plain_text eq 'Hello World!';

t/01-CBC.t  view on Meta::CPAN

use lib '..','../blib/lib','.','./blib/lib';

eval "use Crypt::CBC";
if ($@) {
    print "1..0 # Skipped: Crypt::CBC not installed\n";
    exit;
}

print "1..33\n";

sub test {
    local($^W) = 0;
    my($num, $true,$msg) = @_;
    print($true ? "ok $num\n" : "not ok $num $msg\n");
}

$test_data = <<END;
Mary had a little lamb,
Its fleece was black as coal,
And everywere that Mary went,
That lamb would dig a hole.
END
    ;

eval "use Crypt::CBC";

test(1,!$@,"Couldn't load module");
if ($Crypt::CBC::VERSION <= 2.13) {
    $i = Crypt::CBC->new({key=>'secret', cipher=>'Camellia_PP'});
}
else {
    $i = Crypt::CBC->new(-key=>'secret',-cipher=>'Camellia_PP');

}
test(2,$i,"Couldn't create new object");
test(3,$c = $i->encrypt($test_data),"Couldn't encrypt");
test(4,$p = $i->decrypt($c),"Couldn't decrypt");
test(5,$p eq $test_data,"Decrypted ciphertext doesn't match plaintext");

# now try various truncations of the whole
for (my $c=1;$c<=7;$c++) {
  substr($test_data,-$c) = '';  # truncate



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