Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) RSA Import Public Key from Certificate PEMUses a certificate's public key for RSA encryption. The public key from the certificate .pem file is used.
#include <CkCert.h> #include <CkPublicKey.h> #include <CkRsa.h> void ChilkatSample(void) { CkString strOut; CkCert cert; bool success = cert.LoadFromFile("qa_data/pem/mf_public_rsa.pem"); if (success == false) { strOut.append(cert.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkPublicKey *pubKey = cert.ExportPublicKey(); if (cert.get_LastMethodSuccess() != true) { strOut.append(cert.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkRsa rsa; success = rsa.ImportPublicKeyObj(*pubKey); if (success == false) { strOut.append(rsa.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } delete pubKey; rsa.put_EncodingMode("base64"); const char *encryptedStr = rsa.encryptStringENC("hello",false); strOut.append("encrypted string = "); strOut.append(encryptedStr); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.