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) RSASSA-PSS Algorithm with SHA256 HashingRSA encrypt a SHA256 hash with OAEP padding.
#include <C_CkPrivateKeyW.h> #include <C_CkRsaW.h> void ChilkatSample(void) { HCkPrivateKeyW privkey; BOOL success; HCkRsaW rsa; const wchar_t *sigStr; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. privkey = CkPrivateKeyW_Create(); // Load the private key object from a PEM file. // (To load from a PEM string, call LoadPem instead.) success = CkPrivateKeyW_LoadPemFile(privkey,L"somePath/myPrivateKey.pem"); if (success != TRUE) { wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privkey)); CkPrivateKeyW_Dispose(privkey); return; } rsa = CkRsaW_Create(); // Use RSA-PSS by setting OaepPadding = TRUE CkRsaW_putOaepPadding(rsa,TRUE); // Use SHA256 CkRsaW_putOaepHash(rsa,L"SHA-256"); CkRsaW_ImportPrivateKeyObj(rsa,privkey); // Generate a base64 signature. CkRsaW_putEncodingMode(rsa,L"base64"); sigStr = CkRsaW_signStringENC(rsa,L"String to be signed",L"SHA-256"); if (CkRsaW_getLastMethodSuccess(rsa) != TRUE) { wprintf(L"%s\n",CkRsaW_lastErrorText(rsa)); CkPrivateKeyW_Dispose(privkey); CkRsaW_Dispose(rsa); return; } wprintf(L"Signature: %s\n",sigStr); CkPrivateKeyW_Dispose(privkey); CkRsaW_Dispose(rsa); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.