Crypt-Camellia_PP

 view release on metacpan or  search on metacpan

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

        $dist_l->[$i] = (($src->[($i+$o) % 16] >> $so) & 0xff)
                    | (($src->[($i+$o-1) % 16] << (8 - $so)) & 0xff);
        $dist_r->[$i] = (($src->[($i+8+$o) % 16] >> $so) & 0xff)
                    | (($src->[($i+8+$o-1) % 16] << (8 - $so)) & 0xff);
    }
}

1;
__END__

=head1 NAME

Crypt::Camellia_PP - Pure Perl Camellia 128-bit block cipher module.

=head1 SYNOPSIS

  use Crypt::Camellia_PP;
 
  my $key = pack 'H*', '00000000000000000000000000000000'; 
  my $plain_text = pack 'H*', '00000000000000000000000000000000';
  my $c = Crypt::Camellia->new($key);
  my $cipher_text = $c->encrypt($plain_text);
  

=head1 DESCRIPTION

this module implements the Camellia cipher by Pure Perl.

=head2 Methods

=over 4

=item new($key)

Create a new "Crypt::Camellia_PP" cipher object with the given key (which must be 128 or 192 or 256 bit long).

=item encrypt($data)

Encrypt data. The size of $data must be a 16 bytes.

=item decrypt($data)

Decrypts $data.

=back

=head1 EXAMPLE

=head2 Encrypt and Decrypt

  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!';

=head1 SEE ALSO

L<Crypt::Camellia>,
http://search.cpan.org/dist/Crypt-Camellia/,
http://info.isl.ntt.co.jp/crypt/camellia/

=head1 AUTHOR

Hiroyuki OYAMA E<lt>oyama@module.jpE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2006 by Hiroyuki OYAMA. Japan.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6 or,
at your option, any later version of Perl 5 you may have available.

=cut



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