http://www.perlmonks.org?node_id=1004555

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

I've noticed that when I encrypt something using Crypt::CBC in the resulting string are always the same over multiple executions (using the same passphrase). The remainder of the string is always random. What is going on here? :)
#!/usr/bin/perl use Crypt::CBC; my $cipher = Crypt::CBC->new( -key => 'my secret key blah blah', -cipher => 'Blowfish', ); my $ciphertext = $cipher->encrypt_hex("This data is hush hush blah bla +h"); my $plaintext = $cipher->decrypt_hex($ciphertext); print "$ciphertext\n$plaintext\n";
$ perl t.pl 53616c7465645f5f27aad01783d47f045a963683bb06e3aa959fc83d7c94e1f5aad894 +d37c8df0d93abaaa80fb9e073b9555761f85204457 This data is hush hush blah blah $ perl t.pl 53616c7465645f5fe7e7d95a83e54fb5f8bfc966d07bff9c3db436a17693bad1c31a85 +766026d5f107d5c17adb017b0eeb46afa6f2d6e462 This data is hush hush blah blah $ perl t.pl 53616c7465645f5fec4cc8f6fc8ecbd4ebdeb938b7d4fe0cf028d3eed7a4dce694e001 +0e8cd99a94e799e3241a41d466a6755999bdb58e5f This data is hush hush blah blah $ perl t.pl 53616c7465645f5f639d36c6f916256557b485abb9c26837b235764faa361d2df38484 +42e58ea52bbbff329a3deb6d182d2b4cf04573e016 This data is hush hush blah blah $ perl t.pl 53616c7465645f5fda138a9a74e5c8c3081430fd3b895de307c1c303fbf48afa2d12bd +8c7097d2a3d600819f4c46fb16702536e97d27211c This data is hush hush blah blah