Crypt-TripleDES-CBC

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Changelog for Crypt-TripleDES-CBC

0.006 2016-04-07T07:01:27
 - Added travis and badges (Shantanu Bhadoria)

0.005 2015-03-23T06:41:50Z
 - dist.ini changes, added author website (Shantanu Bhadoria)
 - Fixes #1 (Shantanu Bhadoria)

0.004 2014-12-05T08:14:29Z
 - Fixed Synopsis code, added example1.pl (Shantanu Bhadoria)

MANIFEST  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.043.
.travis.yml
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
examples/example1.pl
lib/Crypt/TripleDES/CBC.pm
t/00-compile.t
t/00-encryption.t
t/00-report-prereqs.dd
t/00-report-prereqs.t
xt/author/critic.t
xt/author/pod-coverage.t
xt/author/pod-spell.t
xt/author/pod-syntax.t
xt/author/test-version.t
xt/release/distmeta.t

META.json  view on Meta::CPAN

{
   "abstract" : "Triple DES in CBC mode Pure implementation",
   "author" : [
      "Shantanu Bhadoria <shantanu@cpan.org> L<https://www.shantanubhadoria.com>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 5.043, CPAN::Meta::Converter version 2.150005",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
      "version" : "2"
   },
   "name" : "Crypt-TripleDES-CBC",
   "no_index" : {
      "directory" : [
         "corpus",
         "examples",
         "inc",
         "t",
         "xt"
      ],
      "package" : [
         "DB"

META.json  view on Meta::CPAN

            "IO::Handle" : "0",
            "IPC::Open3" : "0",
            "Test::More" : "0",
            "Test::Most" : "0.22",
            "blib" : "1.01",
            "perl" : "5.010"
         }
      }
   },
   "provides" : {
      "Crypt::TripleDES::CBC" : {
         "file" : "lib/Crypt/TripleDES/CBC.pm",
         "version" : "0.006"
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/shantanubhadoria/perl-crypt-tripledes-cbc/issues"
      },
      "homepage" : "https://metacpan.org/release/Crypt-TripleDES-CBC",
      "repository" : {
         "type" : "git",
         "url" : "git://github.com/shantanubhadoria/perl-crypt-tripledes-cbc.git",
         "web" : "https://github.com/shantanubhadoria/perl-crypt-tripledes-cbc"
      }
   },
   "version" : "0.006"
}

META.yml  view on Meta::CPAN

---
abstract: 'Triple DES in CBC mode Pure implementation'
author:
  - 'Shantanu Bhadoria <shantanu@cpan.org> L<https://www.shantanubhadoria.com>'
build_requires:
  ExtUtils::MakeMaker: 0
  File::Spec: 0
  File::Temp: 0
  IO::Handle: 0
  IPC::Open3: 0
  Test::More: 0
  Test::Most: 0.22

META.yml  view on Meta::CPAN

  perl: 5.010
configure_requires:
  ExtUtils::MakeMaker: 0
  perl: 5.010
dynamic_config: 0
generated_by: 'Dist::Zilla version 5.043, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: Crypt-TripleDES-CBC
no_index:
  directory:
    - corpus
    - examples
    - inc
    - t
    - xt
  package:
    - DB
provides:
  Crypt::TripleDES::CBC:
    file: lib/Crypt/TripleDES/CBC.pm
    version: 0.006
requires:
  Crypt::DES: 0
  Moose: 0
  perl: 5.010
  strict: 0
  warnings: 0
resources:
  bugtracker: https://github.com/shantanubhadoria/perl-crypt-tripledes-cbc/issues
  homepage: https://metacpan.org/release/Crypt-TripleDES-CBC
  repository: git://github.com/shantanubhadoria/perl-crypt-tripledes-cbc.git
version: 0.006

Makefile.PL  view on Meta::CPAN

# This Makefile.PL for Crypt-TripleDES-CBC was generated by
# Dist::Zilla::Plugin::MakeMaker::Awesome 0.38.
# Don't edit it but the dist.ini and plugins used to construct it.

use strict;
use warnings;

use 5.010;
use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Triple DES in CBC mode Pure implementation",
  "AUTHOR" => "Shantanu Bhadoria <shantanu\@cpan.org> L<https://www.shantanubhadoria.com>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "Crypt-TripleDES-CBC",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010",
  "NAME" => "Crypt::TripleDES::CBC",
  "PREREQ_PM" => {
    "Crypt::DES" => 0,
    "Moose" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0,
    "File::Spec" => 0,
    "File::Temp" => 0,

README  view on Meta::CPAN

NAME

    Crypt::TripleDES::CBC - Triple DES in CBC mode Pure implementation

VERSION

    version 0.006

SYNOPSIS

       use Crypt::TripleDES::CBC;
     
       my $key = pack("H*"
         , "1234567890123456"
         . "7890123456789012");
       my $iv = pack("H*","0000000000000000");
       my $crypt = Crypt::TripleDES::CBC->new(
         key => $key,
         iv  => $iv,
       );
     
       say unpack("H*",$crypt->encrypt(pack("H*","0ABC0F2241535345631FCE")));            # Output F64F2268BF6185A16DADEFD7378E5CE5
       say unpack("H*",$crypt->decrypt(pack("H*","F64F2268BF6185A16DADEFD7378E5CE5")));  # Output 0ABC0F2241535345631FCE0000000000

DESCRIPTION

    Most Modules on CPAN don't do a standards compliant implementation,
    while they are able to decrypt what they encrypt. There are corner
    cases where certain blocks of data in a chain don't decrypt properly.
    This is (almost)a pure perl implementation of TripleDES in CBC mode
    using Crypt::DES to encrypt individual blocks.

ATTRIBUTES

 cipher1

    First Crypt::DES Cipher object generated from the key. This is built
    automatically. Do not change this value from your program.

 cipher2

examples/example1.pl  view on Meta::CPAN

use 5.010;
use Crypt::TripleDES::CBC;

my $key = pack("H*"
    , "1234567890123456"
    . "7890123456789012");
my $iv = pack("H*","0000000000000000");
my $crypt = Crypt::TripleDES::CBC->new(
    key => $key,
    iv  => $iv,
);

say unpack("H*",$crypt->encrypt(pack("H*","0ABC0F2241535345631FCE")));
say unpack("H*",$crypt->decrypt(pack("H*","F64F2268BF6185A16DADEFD7378E5CE5")));

lib/Crypt/TripleDES/CBC.pm  view on Meta::CPAN

use strict;
use warnings;

package Crypt::TripleDES::CBC;

# PODNAME: Crypt::TripleDES::CBC
# ABSTRACT: Triple DES in CBC mode Pure implementation
#
# This file is part of Crypt-TripleDES-CBC
#
# This software is copyright (c) 2016 by Shantanu Bhadoria.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
our $VERSION = '0.006'; # VERSION

# Dependencies

lib/Crypt/TripleDES/CBC.pm  view on Meta::CPAN

}

1;

__END__

=pod

=head1 NAME

Crypt::TripleDES::CBC - Triple DES in CBC mode Pure implementation



=begin html

<p>
<img src="https://img.shields.io/badge/perl-5.10+-brightgreen.svg" alt="Requires Perl 5.10+" />
<a href="https://travis-ci.org/shantanubhadoria/perl-Crypt-TripleDES-CBC"><img src="https://api.travis-ci.org/shantanubhadoria/perl-Crypt-TripleDES-CBC.svg?branch=build/master" alt="Travis status" /></a>
<a href="http://matrix.cpantesters.org/?dist=Crypt-TripleDES-CBC%200.006"><img src="https://badgedepot.code301.com/badge/cpantesters/Crypt-TripleDES-CBC/0.006" alt="CPAN Testers result" /></a>
<a href="http://cpants.cpanauthors.org/dist/Crypt-TripleDES-CBC-0.006"><img src="https://badgedepot.code301.com/badge/kwalitee/Crypt-TripleDES-CBC/0.006" alt="Distribution kwalitee" /></a>
<a href="https://gratipay.com/shantanubhadoria"><img src="https://img.shields.io/gratipay/shantanubhadoria.svg" alt="Gratipay" /></a>
</p>

=end html

=head1 VERSION

version 0.006

=head1 SYNOPSIS

   use Crypt::TripleDES::CBC;
 
   my $key = pack("H*"
     , "1234567890123456"
     . "7890123456789012");
   my $iv = pack("H*","0000000000000000");
   my $crypt = Crypt::TripleDES::CBC->new(
     key => $key,
     iv  => $iv,
   );
 
   say unpack("H*",$crypt->encrypt(pack("H*","0ABC0F2241535345631FCE")));            # Output F64F2268BF6185A16DADEFD7378E5CE5
   say unpack("H*",$crypt->decrypt(pack("H*","F64F2268BF6185A16DADEFD7378E5CE5")));  # Output 0ABC0F2241535345631FCE0000000000

=head1 DESCRIPTION

Most Modules on CPAN don't do a standards compliant implementation, while they
are able to decrypt what they encrypt. There are corner cases where certain
blocks of data in a chain don't decrypt properly. This is (almost)a pure perl
implementation of TripleDES in CBC mode using Crypt::DES to encrypt individual
blocks.

=head1 ATTRIBUTES

=head2 cipher1

First Crypt::DES Cipher object generated from the key. This is built
automatically. Do not change this value from your program.

=head2 cipher2

t/00-compile.t  view on Meta::CPAN

use strict;
use warnings;

# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054

use Test::More;

plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

my @module_files = (
    'Crypt/TripleDES/CBC.pm'
);



# fake home for cpan-testers
use File::Temp;
local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 );


my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib';

t/00-encryption.t  view on Meta::CPAN

use Test::Most 0.22;
use Crypt::TripleDES::CBC;

subtest "decryption using tripledes in cbc mode with nulls in iv" => sub {
    my $algorithm   = "tripledes";
    my $mode        = "cbc";
    my $iv          = pack( "H*", "0000000000000000" );
    my $key         = pack( "H*", "1234567890123456" . "7890123456789012" );
    my $cipher_text = pack( "H*",
            "E9FF3161EE05ABC9"
          . "7ea3cacb991318aa"
          . "585379599b0eaabb"
          . "c4e474ead1956f47"
          . "6755f13f1af5235d" );
    my $obj = Crypt::TripleDES::CBC->new( key => $key, );
    my $plain_text = $obj->decrypt($cipher_text);
    my $expected_plain_hex =
        "5231303000390006"
      . "3030303034370000"
      . "4700074d45465450"
      . "4f53004800093132"
      . "3334353637383900";
    is uc unpack( "H*", $plain_text ), uc $expected_plain_hex,
      "decrypted plaintext matched with expected plaintext";
};

subtest "decryption using tripledes in cbc mode with nulls in iv 2" => sub {
    my $algorithm   = "tripledes";
    my $mode        = "cbc";
    my $iv          = pack( "H*", "0000000000000000" );
    my $key         = pack( "H*", "1234567890123456" . "7890123456789012" );
    my $cipher_text = pack( "H*",
"07e2fe77b41d9a5df983d4ff6199d6e8b7ed076b0322bb81cac378370974c1d4f827e16f952829bb2d8488b7bb67e37af9b87c40184ee619de0aa921671d01ca15246afed93445cde350f595237e8100bf6f8591130ea7a2c6f88427e41e0bfb4ebac7ac3a5edfd6796f20eef963411a503318ef10c24ab15c1e8514c...
    );
    my $obj = Crypt::TripleDES::CBC->new( key => $key, );
    my $plain_text = $obj->decrypt($cipher_text);
    my $expected_plain_hex =
"5232303000020010585858585858585858585858383434360004000C3030303030303030313432300007000A31303233313431353236000E00045858585800160001430025000C33323936303630303030373400260006303035343931002700023030002900083337313131313837002A000C3136383136383333313...
    is uc unpack( "H*", $plain_text ), uc $expected_plain_hex,
      "decrypted plaintext matched with expected plaintext(test 2)";
};

subtest "encryption using tripledes in cbc mode with nulls in iv" => sub {
    my $algorithm  = "tripledes";
    my $mode       = "cbc";
    my $iv         = pack( "H*", "0000000000000000" );
    my $key        = pack( "H*", "1234567890123456" . "7890123456789012" );
    my $plain_text = pack( "H*",
            "5231303000390006"
          . "3030303034370000"
          . "4700074d45465450"
          . "4f53004800093132"
          . "3334353637383900" );
    my $obj = Crypt::TripleDES::CBC->new( key => $key, );
    my $cipher_text = $obj->encrypt($plain_text);
    my $expected_cipher_hex =
        "E9FF3161EE05ABC9"
      . "7ea3cacb991318aa"
      . "585379599b0eaabb"
      . "c4e474ead1956f47"
      . "6755f13f1af5235d";
    is uc unpack( "H*", $cipher_text ), uc $expected_cipher_hex,
      "encrypted ciphertext matched with expected ciphertext";
};

subtest "encryption using tripledes in cbc mode with nulls in iv 2" => sub {
    my $algorithm  = "tripledes";
    my $mode       = "cbc";
    my $iv         = pack( "H*", "0000000000000000" );
    my $key        = pack( "H*", "1234567890123456" . "7890123456789012" );
    my $plain_text = pack( "H*",
"5232303000020010585858585858585858585858383434360004000C3030303030303030313432300007000A31303233313431353236000E00045858585800160001430025000C33323936303630303030373400260006303035343931002700023030002900083337313131313837002A000C3136383136383333313...
    );
    my $obj = Crypt::TripleDES::CBC->new( key => $key, );
    my $cipher_text = $obj->encrypt($plain_text);
    my $expected_cipher_hex =
"07e2fe77b41d9a5df983d4ff6199d6e8b7ed076b0322bb81cac378370974c1d4f827e16f952829bb2d8488b7bb67e37af9b87c40184ee619de0aa921671d01ca15246afed93445cde350f595237e8100bf6f8591130ea7a2c6f88427e41e0bfb4ebac7ac3a5edfd6796f20eef963411a503318ef10c24ab15c1e8514c...
    is uc unpack( "H*", $cipher_text ), uc $expected_cipher_hex,
      "encrypted ciphertext matched with expected ciphertext(test 2)";
};
done_testing;

xt/author/pod-spell.t  view on Meta::CPAN

bhadoria
ascii
DES
decrypt
Shantanu
Bhadoria
https
lib
Crypt
TripleDES
CBC



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