使用Perl Crypt :: PK :: DH的消息长度加密失败

时间:2017-06-13 01:20:34

标签: perl public-key-encryption

为什么消息长度发生变化导致解密失败在下面的代码段中?

我收到以下错误“致命:dh_encrypt_key失败:指定了无效的哈希。在C:/Perl/perl/site/lib/Crypt/PK/DH.pm第225行。”

在为MSWin32-x86-multi-thread,Win10构建的Perl(v5.14.2)上发生

use Crypt::PK::DH;

my $pub = Crypt::PK::DH->new('bob_pub_key.gpg');

print "encrypting secret message... \n";

my $ct = $pub->encrypt("1-2-3-4-5-6-7-8-9-10");  # This Works

# my $ct = $pub->encrypt("1-2-3-4-5-6-7-8-9-10-"); # Why Does This Not Work???

my $priv = Crypt::PK::DH->new('bob_priv_key.gpg');

print "decrypting secret message \n";

my $pt = $priv->decrypt($ct);

print "$pt\n";

0 个答案:

没有答案