Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Is Crypt::CBC really working?

by esskar (Deacon)
on Feb 16, 2005 at 03:52 UTC ( [id://431424]=perlquestion: print w/replies, xml ) Need Help??

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

hi..
i have the following piece of code.
#!/usr/bin/perl use strict; use Crypt::CBC (); use Digest::SHA (); my $pass = 'test'; my $text = 'hutzelhutzelhutzel'; my $key = &Digest::SHA::sha512_hex($pass); print "Key1: $key\n"; my $cbc = Crypt::CBC->new( 'cipher' => 'DES', 'key' => $key, 'regenerate_key' => 0, 'prepend_iv' => 0, ); my $cipher = $cbc->encrypt($text); print "Cipher: $cipher\n"; $cbc = Crypt::CBC->new( 'cipher' => 'DES', 'key' => $key, 'regenerate_key' => 0, 'prepend_iv' => 0, ); print "Plain1: ", $cbc->decrypt($cipher), "\n"; # new password $pass = 'test2'; $key = &Digest::SHA::sha512_hex($pass); print "Key2: $key\n"; $cbc = Crypt::CBC->new( 'cipher' => 'DES', 'key' => $key, 'regenerate_key' => 0, 'prepend_iv' => 0, ); print "Plain2: ", $cbc->decrypt($cipher), "\n";
As you can see, i'm changing the password between the first and second decryption but the results (Plain1, Plain2) are both the same and both are equal to $text. Am I missing something?

This is perl, v5.8.4 built for MSWin32-x86-multi-thread
$Crypt::CBC::VERSION eq '2.12'

Replies are listed 'Best First'.
Re: Is Crypt::CBC really working?
by esskar (Deacon) on Feb 16, 2005 at 04:10 UTC
    oh no

    the CBC->new takes a hash-ref and not a hash
    sorry for my stupidy

    time to go to bed!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://431424]
Approved by K_M_McMahon
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-16 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found