W
Waylen Gumbal
I noticed that if I use a "CBC compatible" crypt module directly, I get
a normal expected result. But if I use CBC with the same cipher type on
the same key and plaintext I get a completely different result.
I've been up and down the perldoc for Crypt::CBC and just can't figure
out why the results differ so much. Because they differ so much you
can't use one method to decrypt the other.
For example:
use Crypt::CBC;
use Crypt::OpenSSL::AES;
$key = 'secretpassphrase';
$text = 'Crypt Test #0001';
my $en1 = new Crypt::OpenSSL::AES($key)->encrypt($text);
my $en2 = new Crypt::CBC(
-key => $key, -cipher => 'Crypt::OpenSSL::AES'
)->encrypt($text);
my $en1h = unpack('H*', $en1);
my $en2h = unpack('H*', $en2);
print "OpenSSL AES\n[$en1h]\n\n";
print "AES via CBC\n[$en2h]\n\n";
__OUTPUT__
OpenSSL AES
[e1f461cdc00f4855b9b2c0367cd3a293]
AES via CBC
[53616c7465645f5f36dd0b8d9b84e278382b8cd329f7020b545c3595c239284d37d4e3dc2d6a2fc97d375675b793b357]
Thanks.
a normal expected result. But if I use CBC with the same cipher type on
the same key and plaintext I get a completely different result.
I've been up and down the perldoc for Crypt::CBC and just can't figure
out why the results differ so much. Because they differ so much you
can't use one method to decrypt the other.
For example:
use Crypt::CBC;
use Crypt::OpenSSL::AES;
$key = 'secretpassphrase';
$text = 'Crypt Test #0001';
my $en1 = new Crypt::OpenSSL::AES($key)->encrypt($text);
my $en2 = new Crypt::CBC(
-key => $key, -cipher => 'Crypt::OpenSSL::AES'
)->encrypt($text);
my $en1h = unpack('H*', $en1);
my $en2h = unpack('H*', $en2);
print "OpenSSL AES\n[$en1h]\n\n";
print "AES via CBC\n[$en2h]\n\n";
__OUTPUT__
OpenSSL AES
[e1f461cdc00f4855b9b2c0367cd3a293]
AES via CBC
[53616c7465645f5f36dd0b8d9b84e278382b8cd329f7020b545c3595c239284d37d4e3dc2d6a2fc97d375675b793b357]
Thanks.