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 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 <C_CkPrivateKeyW.h> #include <C_CkStringBuilderW.h> #include <C_CkRsaW.h> void ChilkatSample(void) { HCkPrivateKeyW privKey; BOOL success; HCkStringBuilderW sbPem; HCkRsaW rsa; const wchar_t *strSigned; const wchar_t *strOriginal; // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. privKey = CkPrivateKeyW_Create(); sbPem = CkStringBuilderW_Create(); CkStringBuilderW_AppendLine(sbPem,L"-----BEGIN RSA PRIVATE KEY-----",TRUE); CkStringBuilderW_AppendLine(sbPem,L"MIIC .... j5A==",TRUE); CkStringBuilderW_AppendLine(sbPem,L"-----END RSA PRIVATE KEY-----",TRUE); success = CkPrivateKeyW_LoadPem(privKey,CkStringBuilderW_getAsString(sbPem)); if (success != TRUE) { wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privKey)); CkPrivateKeyW_Dispose(privKey); CkStringBuilderW_Dispose(sbPem); return; } rsa = CkRsaW_Create(); success = CkRsaW_ImportPrivateKeyObj(rsa,privKey); if (success != TRUE) { wprintf(L"%s\n",CkRsaW_lastErrorText(rsa)); CkPrivateKeyW_Dispose(privKey); CkStringBuilderW_Dispose(sbPem); CkRsaW_Dispose(rsa); return; } CkRsaW_putEncodingMode(rsa,L"base64"); strSigned = CkRsaW_openSslSignStringENC(rsa,L"12345678"); wprintf(L"%s\n",strSigned); strOriginal = CkRsaW_openSslVerifyStringENC(rsa,strSigned); wprintf(L"%s\n",strOriginal); CkPrivateKeyW_Dispose(privKey); CkStringBuilderW_Dispose(sbPem); CkRsaW_Dispose(rsa); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.