I am using Perl to perform CBC DES encryption using the Crypt::CBC library:
#!/usr/bin/perl
use Crypt::CBC;
$key = "\x4A\x6F\xC2\x2A\x44\xE2\xA4\x48";
$iv = "\x00\x00\x00\x00\x00\x00\x00\x00";
$data = "\x51\x55\x45\x53\x54\x49\x4F\x4E";
print "TXT->", $data, "\n";
print "HEX->", unpack("H*", $data), "\n";
$cipher = Crypt::CBC->new(-literal_key => 1,
-key => $key,
-iv => $iv,
-header => 'none');
$ciphertext = $cipher->encrypt($data);
print "ENC->", unpack("H*", $ciphertext), "\n";
The output of the code is:
TXT->QUESTION
HEX->5155455354494f4e
ENC->8220553e09f1b31ba7691f3f7fb52416
My data is conveniently of size 64bits (16 hex digits) which is in accordance with the DES standard. According to Wikipedia
DES is the archetypal block cipher — an algorithm that takes a fixed-length string of plaintext bits and transforms it through a series of complicated operations into another ciphertext bitstring of the same length
Why is it that the encoded output is of longer byte length than the original input?
Thanks.