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
(PureBasic) 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.
IncludeFile "CkCert.pb" IncludeFile "CkRsa.pb" IncludeFile "CkPublicKey.pb" Procedure ChilkatExample() cert.i = CkCert::ckCreate() If cert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkCert::ckLoadFromFile(cert,"qa_data/pem/mf_public_rsa.pem") If success = 0 Debug CkCert::ckLastErrorText(cert) CkCert::ckDispose(cert) ProcedureReturn EndIf pubKey.i = CkCert::ckExportPublicKey(cert) If CkCert::ckLastMethodSuccess(cert) <> 1 Debug CkCert::ckLastErrorText(cert) CkCert::ckDispose(cert) ProcedureReturn EndIf rsa.i = CkRsa::ckCreate() If rsa.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkRsa::ckImportPublicKeyObj(rsa,pubKey) If success = 0 Debug CkRsa::ckLastErrorText(rsa) CkCert::ckDispose(cert) CkRsa::ckDispose(rsa) ProcedureReturn EndIf CkPublicKey::ckDispose(pubKey) CkRsa::setCkEncodingMode(rsa, "base64") encryptedStr.s = CkRsa::ckEncryptStringENC(rsa,"hello",0) Debug "encrypted string = " + encryptedStr CkCert::ckDispose(cert) CkRsa::ckDispose(rsa) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.