Crypt::Blowfish encrypts just a block (your 8 bytes) at a time; you'll need another module to handle real data. Splitting your data in 8-byte blocks, encrypting each, and combining is the obvious but insecure way to do this; Cipher Block Chaining is a method for doing it securely. As Aristotle mentions, Crypt::CBC will do the work for you with a wee bit of effort; Crypt::CBCeasy is supposed to make things Just Work in a way like what you want. You should be able to do this (untested):
use Crypt::CBCeasy;
my $key = pack("H16", "0123456789ABCDEF"); # min. 8 bytes
my $ciphertext = Blowfish::encipher($key, "my string has lots of bytes
+!!!!");
print unpack("H16", $ciphertext), "\n";
my $deciphertext = Blowfish::decipher($key, $ciphertext);
print $deciphertext, "\n";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|