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

Hi ppl,

Still having some dramas with Blowfish decryption - I'd appreciate anyone with knowledge on that, and ISO character sets to have a look at my previous description of the problem.

Thanks

Richard

Replies are listed 'Best First'.
Re: Blowfish problem (still)
by Thelonius (Priest) on May 12, 2003 at 04:05 UTC
    I'm totally baffled by what you are trying to do. Encrypted text is pure binary, not character data. If you need to save the encrypted data in some context where you need text, then encode the encrypted data using uuencode or base64 (or hex or something similar).

    Here is a simple example of how to use Crypt::CBC:

    #!/usr/bin/perl -w use Crypt::CBC; use MIME::Base64; use strict; my $plainin = "Now is the time for all good time for all good men to come to the aid of their party. The quick brown fox jumped over the lazy dog's back.\n"; my $cipher = Crypt::CBC->new( {'key' => 'Richard', 'cipher' => 'Blowfish', }); my $cryptext = $cipher->encrypt($plainin); # if you need to save the cryptext as ASCII, use something # like uuencoding: my $cipher_uuenc = pack("u", $cryptext); # or Base64 encoding (not built in to Perl, may need to install module +) # (Use one or the other, not both. I just show both for pedagogical # purposes). my $cipher_base64 = encode_base64($cryptext); print "cipher_uuenc = $cipher_uuenc\n"; print "cipher_base64 = $cipher_base64\n"; my $cryptext2 = unpack("u", $cipher_uuenc); my $cryptext3 = decode_base64($cipher_base64); if ($cryptext2 eq $cryptext3) { print "Hey, they had better be equal!\n"; } else { print "Something is really screwed up!\n"; } my $cipherx = Crypt::CBC->new( {'key' => 'Richard', 'cipher' => 'Blowfish', }); my $plainout = $cipherx->decrypt($cryptext2); print "plainout =\n$plainout";
Re: Blowfish problem (still)
by tedrek (Pilgrim) on May 12, 2003 at 17:48 UTC
    refer to Re: Re: Re: Blowfish decryption problem for a update and working code. It isn't the escape codes that are the problem. It was a unintended interpolation.

    Tedrek

    I tried to swear at perl and it compiled!