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 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.
#include <CkPrivateKey.h> #include <CkStringBuilder.h> #include <CkRsa.h> void ChilkatSample(void) { CkString strOut; // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkPrivateKey privKey; bool success; CkStringBuilder sbPem; sbPem.AppendLine("-----BEGIN RSA PRIVATE KEY-----",true); sbPem.AppendLine("MIIC .... j5A==",true); sbPem.AppendLine("-----END RSA PRIVATE KEY-----",true); success = privKey.LoadPem(sbPem.getAsString()); if (success != true) { strOut.append(privKey.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkRsa rsa; success = rsa.ImportPrivateKeyObj(privKey); if (success != true) { strOut.append(rsa.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } rsa.put_EncodingMode("base64"); const char *strSigned = rsa.openSslSignStringENC("12345678"); strOut.append(strSigned); strOut.append("\r\n"); const char *strOriginal = rsa.openSslVerifyStringENC(strSigned); strOut.append(strOriginal); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.