Perl
Perl
RSA Import Public Key from Certificate PEM
See more RSA Examples
Uses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.Chilkat Perl Downloads
use chilkat();
$success = 0;
$cert = chilkat::CkCert->new();
$success = $cert->LoadFromFile("qa_data/pem/mf_public_rsa.pem");
if ($success == 0) {
print $cert->lastErrorText() . "\r\n";
exit;
}
$pubKey = chilkat::CkPublicKey->new();
$cert->GetPublicKey($pubKey);
$rsa = chilkat::CkRsa->new();
$rsa->UsePublicKey($pubKey);
$rsa->put_EncodingMode("base64");
$encryptedStr = $rsa->encryptStringENC("hello",0);
print "encrypted string = " . $encryptedStr . "\r\n";