Направьте в правильную сторону на perl-e пытаюсь подписать строку у меня получается 25 строк подпись
а в примере По для которого эта подпись нужна 1 строка такого вида
's43asdDsfAnDgt+4mRFtWD9+xFEnPtq5lFwQ5yQMCVsEY0Ou7CS1PhkZRPwdzBVR6QwO2tX4xPZzFI87DpYTMg=='
Подскажите какой метод нужно использовать ? может SignedCode ?
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
use MIME::Base64;
my $StoreName = 'MY';
my $cert ;
my $certforsign = Win32::OLE->new('CAPICOM.Certificate') or die "Could create object: ".Win32::FormatMessage Win32::GetLastError()."\n";;
my $Store = Win32::OLE->new('CAPICOM.Store') or die "Could create object: ".Win32::FormatMessage Win32::GetLastError()."\n";
my $Signer = Win32::OLE->new('CAPICOM.Signer') or die "Oops, cannot start CAPICOM.Signer";
my $SignedData = Win32::OLE->new('CAPICOM.SignedData') or die "Oops, cannot start CAPICOM.SignedData";
use constant {
Unknown => 0,
Sign => 1,
Timestamp => 2,
Verify => 3,
CAPICOM_LOCAL_MACHINE_STORE => 1,
CAPICOM_CURRENT_USER_STORE => 2,
CAPICOM_SMART_CARD_USER_STORE => 4,
CAPICOM_OTHER_STORE => 1,
CAPICOM_STORE_OPEN_READ_ONLY => 0,
CAPICOM_KEY_STORAGE_DEFAULT => 0,
CAPICOM_CERTIFICATE_FIND_SHA1_HASH => 0,
CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME => 1,
CAPICOM_CERTIFICATE_FIND_ROOT_NAME => 3,
CAPICOM_ENCODE_ANY => 0xffffffff,
CAPICOM_ENCODE_BASE64 => 0,
CAPICOM_ENCODE_BINARY => 1,
CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT => 0,
CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN => 1,
CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY => 2,
CAPICOM_VERIFY_SIGNATURE_ONLY => 0,
CAPICOM_VERIFY_SIGNATURE_AND_CERTIFICATE => 1,
};
my $Masksign ='cb72197e56ed78dbeeaac027c6268b159a6c6238';
$Store->Open(CAPICOM_CURRENT_USER_STORE ,$StoreName,CAPICOM_STORE_OPEN_READ_ONLY);
my $Certificates = $Store->Certificates;
if ($Certificates->Count > 0)
{
$Certificates = $Certificates->Find(CAPICOM_CERTIFICATE_FIND_SHA1_HASH, $Masksign);
}
{
if ($Certificates->Count == 0)
{
print "Error!\n";
exit;
}
if ($Certificates->Count == 1)
{
$Signer->LetProperty('Certificate',$Certificates->Item(1));
last;
}
print "Error! 2!\n";
exit;
}
undef $Certificates;
undef $Store;
my $ContentToSign ='aa';
$SignedData->{'Content'} = Variant(VT_UI1, $ContentToSign);
my $Message = $SignedData->Sign($Signer, 1, CAPICOM_ENCODE_BASE64);
$SignedData->Verify($Message, 1, 0);
print $Message ;