Hi I want to crypt and later decrypt a password that may vary in size from 4 to 15 characters in length.
Tried to use Crypt::DES to accomplish this. I used the example provided and did this:
use Crypt::DES;
my $plaintext= shift;
my $key = pack("H16", "1234567890ABCDEF");
my $cipher = new Crypt::DES $key;
my $ciphertext = $cipher->encrypt($plaintext); # NB - 8 bytes
print unpack("H16", $ciphertext), "\n";
sub decryptpw
{
my $key = pack("H16", "1234567890ABCDEF");
my $ciphertext=shift;
my $cipher = new Crypt::DES $key;
my $plaintext = $cipher->decrypt(pack("H16",$ciphertext));
return $plaintext;
}
my code only works with 8 character passwords. How can I make it work for varying length passwords from 4 - 15 characters in length? I'm assuming it has to do with the key size. What do I need to do here?
thanks
exit;