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";

In reply to Re: Blowfish problem (still) by Thelonius
in thread Blowfish problem (still) by richard_mortimer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.