Crypt::DES(3pm)

Crypt::DES3pm

Perl des encryption module

Usage

        use Crypt::DES;
        my $key = pack("H16", "0123456789ABCDEF");
        my $cipher = Crypt::DES->new($key);
        my $ciphertext = $cipher->encrypt($plaintext);
        my $plaintext = $cipher->decrypt($ciphertext);

Overview

The module implements the Crypt::CBC interface, which has the following methods

blocksize
keysize
encrypt
decrypt

Functions

blocksize

Returns the size (in bytes) of the block cipher.

keysize

Returns the size (in bytes) of the key. Optimal size is 8 bytes.

new
        my $cipher = Crypt::DES->new($key);

This creates a new Crypt::DES BlockCipher object, using $key, where $key is a key of keysize() bytes.

encrypt
        my $cipher = Crypt::DES->new($key);
        my $ciphertext = $cipher->encrypt($plaintext);

This function encrypts $plaintext and returns the $ciphertext where $plaintext and $ciphertext should be of blocksize() bytes.

decrypt
        my $cipher = Crypt::DES->new($key);
        my $plaintext = $cipher->decrypt($ciphertext);

This function decrypts $ciphertext and returns the $plaintext where $plaintext and $ciphertext should be of blocksize() bytes.

Security Considerations

This module is not deprecated as there may still be a reason to encrypt and decrypt using DES. However, DES is known to be weak. In 2026 a standard laptop can brute-force a DES key in a few days. DO NOT use DES (or this module) with any expectation of security.

Examples

        my $key = pack("H16", "0123456789ABCDEF");
        my $cipher = Crypt::DES->new($key);
        my $ciphertext = $cipher->encrypt("plaintex");  # NB - 8 bytes
        print unpack("H16", $ciphertext), "\n";
        my $plaintext = $cipher->decrypt($ciphertext);
        print $plaintext, "\n";

Notes

Do note that DES only uses 8 byte keys and only works on 8 byte data blocks. If you're intending to encrypt larger blocks or entire files, please use Crypt::CBC in conjunction with this module. See the Crypt::CBC documentation for proper syntax and use.

Also note that the DES algorithm is, by today's standard, weak encryption. CryptX (Crypt::Cipher::AES) is recommended if you want to replace Crypt::DES in a Crypt::CBC use case. Otherwise, replacing it with something like Crypt::AuthEnc::GCM would be recommended.

Maintainer

This single-algorithm package and cross-platform code is maintained by Dave Paris <[email protected]>.

Timothy Legge <[email protected]> started maintaining this module as of version 2.08.

Releases

12 releases since Debian 3.1 (Sarge); the text changed 10 times.

  1. 3.1
  2. 4.0
  3. 5.0–6.0
  4. 7
  5. 8
  6. 9
  7. 10
  8. 11
  9. 12
  10. 13
  11. Arch

From perl-crypt-des 2.09-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.