Crypt::CBC Encryption Verification

A tutorial example is provided to verify Crypt::CBC against the Blowfish CBC test vector published at

Okay, I think we have learned enough on how to use the Crypt::CBC module. Now we needed to verify its output against existing Blowfish CBC test vectors.

When I search the Internet, I only see one published test vector for Blowfish in CBC mode at

chaining mode test data
key[16]   = 0123456789ABCDEFF0E1D2C3B4A59687
iv[8]     = FEDCBA9876543210
data[29]  = "7654321 Now is the time for " (includes trailing '\0')
data[29]  = 37363534333231204E6F77206973207468652074696D6520666F722000
cbc cipher text

I think we can run my example script,, to validate this:

C:\herong>perl \
   0123456789ABCDEFF0E1D2C3B4A59687 FEDCBA9876543210 \
Crypt::CBC Blowfish Object Test - output in Hex:
   Secret Key     (0123456789ABCDEFF0E1D2C3B4A59687)
   IV             (FEDCBA9876543210)
   Plaintext      (37363534333231204E6F772069732074
Creating Crypt::CBC with Blowfish Object ...
Encrypting plaintext...
   Ciphertext     (6b77b4d63006dee605b156e274039793
Decrypting ciphertext...
   Decrypted text (37363534333231204e6f772069732074
   Pass Phrase    ()
   IV             (fedcba9876543210)

Congratulations! The ciphertext matches with what given in the test vector. Now we can confidently say that Crypt::CBC and Crypt::Blowfish modules work correctly.

Table of Contents

 About This Book

 Blowfish Cipher Algorithm

 Perl Crypt::Blowfish Module

 Perl Crypt::ECB Perl Module

Perl Crypt::CBC Module

 What is Crypt::CBC

 Installing Crypt::CBC 2.33 with ActivePerl

 Crypt::CBC Encryption with Literal Keys

 Crypt::CBC Literal Key Error Cases

 Crypt::CBC Encryption with Crypt::Blowfish Objects

 Crypt::CBC Operation Simulation

Crypt::CBC Encryption Verification

 Blowfish CBC 2-Block Test Vectors

 Crypt::CBC Prepending IV to Ciphertext

 Crypt::CBC Encryption with Salted Keys

 Crypt::CBC Salted Key Test Cases

 Crypt::CBC Secret Key and IV Algorithm

 Crypt::CBC Encryption with Random Salt

 Crypt::CBC Padding Options

 Crypt::CBC Padding Option Tests

 Crypt::CBC Blowfish Encryption Summary

 Perl Crypt::CFB Perl Module

 OpenSSL "enc -bf-ecb" for Blowfish/ECB Encryption

 OpenSSL "enc -bf-cbc" for Blowfish/CBC Encryption

 OpenSSL "enc -bf-cfb" for Blowfish/CFB Encryption

 OpenSSL "enc -bf-ofb" for Blowfish/OFB Encryption

 PHP Mcrypt Extension for Blowfish

 Blowfish 8-Bit Cipher in PHP


 Full Version in PDF/EPUB