Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C) 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 <C_CkCertW.h> #include <C_CkPublicKeyW.h> #include <C_CkRsaW.h> void ChilkatSample(void) { HCkCertW cert; BOOL success; HCkPublicKeyW pubKey; HCkRsaW rsa; const wchar_t *encryptedStr; cert = CkCertW_Create(); success = CkCertW_LoadFromFile(cert,L"qa_data/pem/mf_public_rsa.pem"); if (success == FALSE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkCertW_Dispose(cert); return; } pubKey = CkCertW_ExportPublicKey(cert); if (CkCertW_getLastMethodSuccess(cert) != TRUE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkCertW_Dispose(cert); return; } rsa = CkRsaW_Create(); success = CkRsaW_ImportPublicKeyObj(rsa,pubKey); if (success == FALSE) { wprintf(L"%s\n",CkRsaW_lastErrorText(rsa)); CkCertW_Dispose(cert); CkRsaW_Dispose(rsa); return; } CkPublicKeyW_Dispose(pubKey); CkRsaW_putEncodingMode(rsa,L"base64"); encryptedStr = CkRsaW_encryptStringENC(rsa,L"hello",FALSE); wprintf(L"encrypted string = %s\n",encryptedStr); CkCertW_Dispose(cert); CkRsaW_Dispose(rsa); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.