DES(3)

πŸ’– NAME πŸ’–

Crypt::DES β€” Perl DES encryption module, and yes bestie this is the DES(3) page πŸ’… iykyk.

✨ SYNOPSIS ✨

use Crypt::DES;

🌸 DESCRIPTION 🌸

Okay so the module implements the Crypt::CBC interface, and that interface has these methods:

The page lists them as blocksize =item keysize =item encrypt =item decrypt (POD formatting said what it said πŸ’€), and lowkey the methods are:

  • blocksize
  • keysize
  • encrypt
  • decrypt

πŸ”₯ FUNCTIONS πŸ”₯

πŸŽ€ blocksize

Returns the size (in bytes) of the block cipher. Slay, that's the block vibe check.

πŸ”‘ keysize

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

πŸ’« new

my $cipher = new Crypt::DES $key;

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

πŸ•΅οΈβ€β™€οΈ encrypt

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

This function encrypts $plaintext and returns the $ciphertext, where $plaintext and $ciphertext should be of blocksize() bytes. Keep it block-sized, periodt.

πŸ”“ decrypt

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

This function decrypts $ciphertext and returns the $plaintext, where $plaintext and $ciphertext should be of blocksize() bytes. Reverse slay πŸ’….

🌈 EXAMPLE 🌈

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

Copy-paste this and watch the hex print, bestie. It's giving tiny but iconic demo.

πŸ’€ NOTES πŸ’€

Do note that DES only uses 8 byte keys and only works on 8 byte data blocks. Literally no bigger keys, no bigger blocks β€” that's the rule.

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. It's giving β€œbring a friend” energy.

Also note that the DES algorithm is, by today's standard, weak encryption. Crypt::Blowfish is highly recommended if you're interested in using strong encryption and a faster algorithm. So if you want strong + faster, ngl, Blowfish is the rec, okay? fr fr.

πŸ¦‹ SEE ALSO πŸ¦‹

Obsessed with these references, check them out:

  • Crypt::Blowfish
  • Crypt::IDEA

Bruce Schneier, Applied Cryptography, 1995, Second Edition, published by John Wiley & Sons, Inc.

The implementation of the DES algorithm was developed by, and is copyright of, Eric Young (eay@mincom.oz.au). Other parts of the perl extension and module are copyright of Systemics Ltd (http://www.systemics.com/). Cross-platform work and packaging for single algorithm distribution is copyright of W3Works, LLC.

🫢 MAINTAINER 🫢

This single-algorithm package and cross-platform code is maintained by Dave Paris <amused@pobox.com>. Say hi, be nice 🫢.


πŸ’Œ cute sign-off: this page is from perl v5.42.0, dated 2024-05-07, and it's the DES(3) manual page. Catch you later, bestie πŸ’–βœ¨

πŸ“¦ where this page comes from