我正在看Crypt :: CBC lib,我误解了一些东西......下面是一个例子:
#!/usr/bin/env perl
use warnings;
use strict;
use Crypt::CBC;
my $cipher = Crypt::CBC->new(
-key => pack("H*","0011223344556677"),
-iv => pack("H*","AABBCCDDEEFF0011"),
-header => "none",
-padding=> "null",
-cipher => "Crypt::DES");
my $plaintext = $cipher->decrypt(pack("H*","0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"));
print unpack("H*",$plaintext)."\n";
此脚本打印字符串:
a732b731fdcb5dbe0caa3e8b9a9f90400caa3e8b9a9f90400caa3e8b9a9f90400caa3e8b9a9f90400caa3e8b9a9f90400caa3e8b9a9f9040
应该是:
D7ED316D5F2C1F1D7C75B8D73878D2E37C75B8D73878D2E37C75B8D73878D2E37C75B8D73878D2E37C75B8D73878D2E37C75B8D73878D2E3
我使用CrypTool 2.0软件和http://des.online-domain-tools.com/tool-form-submit/来获得此结果。
有什么想法吗?
我已用 -literal_key =>修复了此问题1,参数。
#!/usr/bin/env perl
use warnings;
use strict;
use Crypt::CBC;
my $cipher = Crypt::CBC->new(
-literal_key => 1,
-key => pack("H*","0011223344556677"),
-iv => pack("H*","AABBCCDDEEFF0011"),
-header => "none",
-padding=> "null",
-cipher => "Crypt::DES");
my $plaintext = $cipher->decrypt(pack("H*","0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"));
print unpack("H*",$plaintext)."\n";
答案 0 :(得分:0)
我已用 -literal_key =>修复了此问题1,参数。
#!/usr/bin/env perl
use warnings;
use strict;
use Crypt::CBC;
my $cipher = Crypt::CBC->new(
-literal_key => 1,
-key => pack("H*","0011223344556677"),
-iv => pack("H*","AABBCCDDEEFF0011"),
-header => "none",
-padding=> "null",
-cipher => "Crypt::DES");
my $plaintext = $cipher->decrypt(pack("H*","0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"));
print unpack("H*",$plaintext)."\n";