Crypt-DES_PP

 view release on metacpan or  search on metacpan

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

	}		
    }
    
    $l = (($l >> 1) & 0x7fffffff) | ($l << 31);
    $r = (($r >> 1) & 0x7fffffff) | ($r << 31);
    # Clear the top bits on machines with 8byte longs.
    $l &= 0xffffffff;
    $r &= 0xffffffff;
    
    # Swap $l and $r.
    # We will not do the swap so just remember they are
    # Reversed for the rest of the subroutine
    # Luckily FP fixes this problem :-)
    
    $t = (($r >> 1) ^ $l) & 0x55555555;
    $l ^= $t;
    $r ^= $t << 1;
    $t = (($l >> 8) ^ $r) & 0x00ff00ff;
    $r ^= $t;
    $l ^= $t << 8;
    $t = (($r >> 2) ^ $l) & 0x33333333;
    $l ^= $t;
    $r ^= $t << 2;
    $t = (($l >> 16) ^ $r) & 0x0000ffff;
    $r ^= $t;
    $l ^= $t << 16;
    $t = (($r >> 4) ^ $l) & 0x0f0f0f0f;
    $l ^= $t;
    $r ^= $t << 4;
    
    pack "VV", $l, $r;
}

1;

__END__

=head1 NAME

Crypt::DES_PP - Perl extension for DES encryption

=head1 SYNOPSIS

use Crypt::DES_PP;

    $des = Crypt::DES_PP->new ($key);
    $cipher = $des->encrypt ($plain);
    $plain = $des->decrypt ($cipher);
    $blocksize = $des->blocksize;
    $keysize = $des->keysize;

=head1 DESCRIPTION

The Data Encryption Standard (DES), also known as Data Encryption 
Algorithm  (DEA) is a semi-strong encryption and decryption algorithm.  

The module is 100 % compatible to Crypt::DES but is implemented 
entirely in Perl.  That means that you do not need a C compiler to 
build and install this extension.  

The module implements the Crypt::CBC interface.  You are encouraged
to read the documentation for Crypt::CBC if you intend to use this
module for Cipher Block Chaining.

The minimum (and maximum) key size is 8 bytes.  Shorter keys will
cause an exception, longer keys will get silently truncated.  Data
is encrypted and decrypted in blocks of 8 bytes.

The module implements the Ultra-Fast-Crypt (UFC) algorithm as found
for example in the GNU libc.  On the Perl side a lot has been done
in order to make the module as fast as possible (function inlining,
use integer, ...).

Note: For performance issues the source code for the module is
first preprocessed by m4.  That means that you need an m4 macro
processor in order to hack on the sources.  This is of no concern
for you if you only want to use the module, the preprocessed output
is always included in the distribution.

=head1 BUGS

Nothing known.  The module has not been tested on 64 bit architectures.

=head1 AUTHOR

This implementation was written by Guido Flohr (guido@imperia.net).
It is available under the terms of the Lesser GNU General Public
License (LGPL) version 2 or - at your choice - any later version,
see the file ``COPYING.LIB''.

The original C implementation of the Ultra-Fast-Crypt algorithm
was written by Michael Glad (glad@daimi.aau.dk) and has been donated to 
the Free Software Foundation, Inc.  It is covered by the GNU library 
license version 2, see the file ``COPYING.LIB''.

=head1 SEE ALSO

Crypt::CBC(3), Crypt::DES(3), perl(1), m4(1).

=cut

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
tab-width: 4
End:                                                                            



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