使用Crypt :: RSA在perl中进行数据签名

时间:2014-12-04 04:08:24

标签: perl cryptography rsa

我尝试在通过HTTPS连接发送到服务器之前签署我的数据。我遇到的问题是,当我从id_rsa读取我的私钥时,它会给出错误。我的代码是

use strict;
use warnings;
use Crypt::RSA;

my $rsa = new Crypt::RSA ( ES => 'PKCS1v15' );
my $pkey  = new Crypt::RSA::Key::Private ( Filename => '/home/abc/.ssh/id_rsa' );

print $pkey;

在打印时,它会出现Bareword found where operator expectedNumber found where operator expected等错误。

我无法理解可能存在的问题。

错误消息以这种方式启动Number found where operator expected at (eval 21) line 6, near "ZapzlA9gZ8 23" (Missing semicolon on previous line?) Bareword found where operator expected at (eval 21) line 6, near "23mqj2RsKOF0Lal7YbjYFkDE7YrLPktf0FNNYvn6BjKZDlyQfpWnk8dP3crjoown" (Missing operator before mqj2RsKOF0Lal7YbjYFkDE7YrLPktf0FNNYvn6BjKZDlyQfpWnk8dP3crjoown?) Number found where operator expected at (eval 21) line 9, near "QUgHQAJ4R 34" (Missing semicolon on previous line?) Bareword found where operator expected at (eval 21) line 9, near "34Csy0lcx" (Missing operator before Csy0lcx?) Having no space between pattern and following word is deprecated at (eval 21) line 10.

在上一行和之后的行中有很多行,消息是

Can't use an undefined value as a HASH reference at Number found where operator expected at /usr/local/share/perl/5.14.2/Crypt/RSA/Key/Private.pm line 217.

1 个答案:

答案 0 :(得分:0)

如果可以,我建议尝试使用Crypt :: OpenSSL :: RSA。