Crypt::DES - Perl DES encryption module
use Crypt::DES;
my $cipher = new Crypt::DES $key;
This creates a new Crypt::DES BlockCipher object, using $key, where $key is a key of "keysize()" bytes.
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.
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.
my $key = pack("H16", "0123456789ABCDEF"); my $cipher = new Crypt::DES $key; my $ciphertext = $cipher->encrypt("plaintex"); # NB - 8 bytes print unpack("H16", $ciphertext), "\n";
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.
Bruce Schneier, Applied Cryptography, 1995, Second Edition, published by John Wiley & Sons, Inc.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |