Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Encrypting strings with more than 8 bytes.

by athomason (Curate)
on Jan 13, 2006 at 05:07 UTC ( #522884=note: print w/ replies, xml ) Need Help??


in reply to Encrypting strings with more than 8 bytes.

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


Comment on Re: Encrypting strings with more than 8 bytes.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://522884]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2015-07-28 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls