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 Sign using Base64 Private KeySigns a string using a non-encrypted RSA private key in base64 encoding. Returns the RSA signature as a base64 string.
IncludeFile "CkStringBuilder.pb" IncludeFile "CkPrivateKey.pb" IncludeFile "CkRsa.pb" Procedure ChilkatExample() ; This requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. privKey.i = CkPrivateKey::ckCreate() If privKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i sbPem.i = CkStringBuilder::ckCreate() If sbPem.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppendLine(sbPem,"-----BEGIN RSA PRIVATE KEY-----",1) CkStringBuilder::ckAppendLine(sbPem,"MIIC .... j5A==",1) CkStringBuilder::ckAppendLine(sbPem,"-----END RSA PRIVATE KEY-----",1) success = CkPrivateKey::ckLoadPem(privKey,CkStringBuilder::ckGetAsString(sbPem)) If success <> 1 Debug CkPrivateKey::ckLastErrorText(privKey) CkPrivateKey::ckDispose(privKey) CkStringBuilder::ckDispose(sbPem) ProcedureReturn EndIf rsa.i = CkRsa::ckCreate() If rsa.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkRsa::ckImportPrivateKeyObj(rsa,privKey) If success <> 1 Debug CkRsa::ckLastErrorText(rsa) CkPrivateKey::ckDispose(privKey) CkStringBuilder::ckDispose(sbPem) CkRsa::ckDispose(rsa) ProcedureReturn EndIf CkRsa::setCkEncodingMode(rsa, "base64") strSigned.s = CkRsa::ckOpenSslSignStringENC(rsa,"12345678") Debug strSigned strOriginal.s = CkRsa::ckOpenSslVerifyStringENC(rsa,strSigned) Debug strOriginal CkPrivateKey::ckDispose(privKey) CkStringBuilder::ckDispose(sbPem) CkRsa::ckDispose(rsa) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.