Crypt-DES_EDE3

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

$Id: Changes,v 1.2 2001/09/15 03:41:51 btrott Exp $

Revision history for Crypt::DES_EDE3

0.03 -- Mon Oct 21 22:39:27 ADT 2024
    [Change Log]
    - Release 0.02-TRIAL as 0.03
    - Basically a rerelease of 0.01 packaged with Dist::Zilla

    [Detailed Changes]
    - 658af68 v0.02
    - e81a2bb Move tests to a test directory
    - 7dc5eb0 Convert to Dist::Zilla for the build

META.json  view on Meta::CPAN

   },
   "name" : "Crypt-DES_EDE3",
   "prereqs" : {
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "Crypt::DES" : "0"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "homepage" : "https://github.com/perl-Crypt-OpenPGP/Crypt-DES_EDE3",
      "repository" : {
         "type" : "git",
         "url" : "https://github.com/perl-Crypt-OpenPGP/Crypt-DES_EDE3.git",
         "web" : "https://github.com/perl-Crypt-OpenPGP/Crypt-DES_EDE3"

META.yml  view on Meta::CPAN

configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Crypt-DES_EDE3
requires:
  Crypt::DES: '0'
resources:
  homepage: https://github.com/perl-Crypt-OpenPGP/Crypt-DES_EDE3
  repository: https://github.com/perl-Crypt-OpenPGP/Crypt-DES_EDE3.git
version: '0.03'
x_generated_by_perl: v5.38.2
x_maintainers:
  - 'Timothy Legge <timlegge@gmail.com>'
x_serialization_backend: 'YAML::Tiny version 1.74'
x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Triple-DES EDE encryption/decryption",
  "AUTHOR" => "Benjamin Trott <ben\@rhumba.pair.com>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "Crypt-DES_EDE3",
  "LICENSE" => "perl",
  "NAME" => "Crypt::DES_EDE3",
  "PREREQ_PM" => {
    "Crypt::DES" => 0
  },
  "VERSION" => "0.03",
  "test" => {
    "TESTS" => "t/*.t"
  }
);


my %FallbackPrereqs = (
  "Crypt::DES" => 0
);


unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
  delete $WriteMakefileArgs{TEST_REQUIRES};
  delete $WriteMakefileArgs{BUILD_REQUIRES};
  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}

README  view on Meta::CPAN

$Id: README,v 1.1.1.1 2001/09/15 03:24:02 btrott Exp $

This is Crypt::DES_EDE3, a module implementing Triple-DES EDE
(encrypt-decrypt-encrypt) encryption and decryption.

PREREQUISITES

    * Crypt::DES

INSTALLATION

Crypt::DES_EDE3 installation is straightforward. If your cpan shell
is set up, you should just be able to do

    % perl -MCPAN -e 'install Crypt::DES_EDE3'

If you don't like that, you can download the distribution; the
latest version on CPAN can be found in

    ftp://ftp.cpan.org/pub/CPAN/authors/id/B/BT/BTROTT/

Download it, unpack it, then build it as per the usual:

    % perl Makefile.PL
    % make && make test

dist.ini  view on Meta::CPAN


[Git::GatherDir]
exclude_filename = Makefile.PL

[CopyFilesFromBuild::Filtered]
copy = Makefile.PL

[OurPkgVersion]

[Prereqs]
Crypt::DES = 0

[Prereqs/TestRequires]

[GithubMeta]
remote = upstream

[NextRelease]
format = %v -- %{EEE MMM dd HH:mm:ss VVV yyyy}d
filename = Changes

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

# $Id: DES_EDE3.pm,v 1.2 2001/09/15 03:41:09 btrott Exp $

package Crypt::DES_EDE3;
use strict;

use Crypt::DES;
use vars qw( $VERSION );

our $VERSION = '0.03'; #VERSION

sub new {
    my $class = shift;
    my $ede3 = bless {}, $class;
    $ede3->init(@_);
}

sub keysize   { 24 }
sub blocksize { 8 }

sub init {
    my $ede3 = shift;
    my($key) = @_;
    for my $i (1..3) {
        $ede3->{"des$i"} = Crypt::DES->new(substr $key, 8*($i-1), 8);
    }
    $ede3;
}

sub encrypt {
    my($ede3, $block) = @_;
    $ede3->{des3}->encrypt(
        $ede3->{des2}->decrypt(
            $ede3->{des1}->encrypt($block)
        )

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

            $ede3->{des3}->decrypt($block)
        )
    );
}

1;
__END__

=head1 NAME

Crypt::DES_EDE3 - Triple-DES EDE encryption/decryption

=head1 SYNOPSIS

    use Crypt::DES_EDE3;
    my $ede3 = Crypt::DES_EDE3->new($key);
    $ede3->encrypt($block);

=head1 DESCRIPTION

I<Crypt::DES_EDE3> implements DES-EDE3 encryption. This is triple-DES
encryption where an encrypt operation is encrypt-decrypt-encrypt, and
decrypt is decrypt-encrypt-decrypt. This implementation uses I<Crypt::DES>
to do its dirty DES work, and simply provides a wrapper around that
module: setting up the individual DES ciphers, initializing the keys,
and performing the encryption/decryption steps.

DES-EDE3 encryption requires a key size of 24 bytes.

You're probably best off not using this module directly, as the I<encrypt>
and I<decrypt> methods expect 8-octet blocks. You might want to use the
module in conjunction with I<Crypt::CBC>, for example. This would be
DES-EDE3-CBC, or triple-DES in outer CBC mode.

=head1 USAGE

=head2 $ede3 = Crypt::DES_EDE3->new($key)

Creates a new I<Crypt::DES_EDE3> object (really, a collection of three DES
ciphers), and initializes each cipher with part of I<$key>, which should be
at least 24 bytes. If it's longer than 24 bytes, the extra bytes will be
ignored.

Returns the new object.

=head2 $ede3->encrypt($block)

Encrypts an 8-byte block of data I<$block> using the three DES ciphers in
an encrypt-decrypt-encrypt operation.

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

=head2 $ede3->blocksize

Returns the block size (8).

=head2 $ede3->keysize

Returns the key size (24).

=head1 LICENSE

Crypt::DES_EDE3 is free software; you may redistribute it and/or modify
it under the same terms as Perl itself.

=head1 AUTHOR & COPYRIGHTS

Crypt::DES_EDE3 is Copyright 2001 Benjamin Trott, ben@rhumba.pair.com. All
rights reserved.

=cut

t/test.t  view on Meta::CPAN

# $Id: test.pl,v 1.2 2001/09/15 03:38:24 btrott Exp $

use strict;

use Test;
use Crypt::DES_EDE3;
use strict;

BEGIN { plan tests => 7 }

my $des = Crypt::DES_EDE3->new( pack 'H64', '0123456789ABCDEF' x 4 );
ok($des);
ok($des->keysize, 24);

my $enc = $des->encrypt( _checkbytes() );
ok($enc);
my $dec = $des->decrypt($enc);
ok($dec);

ok( vec($dec, 0, 8) == vec($dec, 2, 8) );
ok( vec($dec, 1, 8) == vec($dec, 3, 8) );



( run in 0.328 second using v1.01-cache-2.11-cpan-9a3d99fc6dc )