http://www.perlmonks.org?node_id=155526

DaWolf has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, fellows.

I'm trying to do some basic operations using Crypt::Blowfish here, but I'm not getting it too good as I thought I would.

This module looks very simple to use, but I'm missing something here.

I was sucessfull to encrypt a string but can't decrypt it. I've followed the module documentation and did like this:

To encrypt:
#!c:/perl use Crypt::Blowfish; while ($pass = <>) { chomp $pass; $key = pack ("H16","0123456789ABCDEF"); $cipher = new Crypt::Blowfish $key; $ciphertext = $cipher->encrypt("$pass"); print unpack ("H16",$ciphertext),"\n"; }
and, to decrypt:
#!c:/perl use Crypt::Blowfish; while ($pass = <>) { chomp $pass; $key = pack ("H16","0123456789ABCDEF"); $cipher = new Crypt::Blowfish $key; $ciphertext = $cipher->decrypt("$pass"); print unpack ("H16",$ciphertext),"\n"; }
So, if I try to put the encrypted string for the module to decrypt it, it returns this:

"input must be 8 bytes long at C:/Perl/site/lib/Crypt/Blowfish.pm line 68, <> line 1"

Can anyone explain this to me? Why it doesn't works? If it must be 8 bytes long why does it generate a longer string?

Thanks in advance, brothers.

Er Galvão Abbott
a.k.a. Lobo, DaWolf
Webdeveloper