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) Generate RSA Key and return Base64 PKCS8 Private KeyDemonstrates how to generate a new 2048-bit RSA private key and returns the Base64 encoded PKCS8 representation of the private key.
#include <CkRsa.h> #include <CkPrivateKey.h> void ChilkatSample(void) { CkString strOut; CkRsa rsa; bool success; // Generate a 2048-bit key. Chilkat RSA supports // key sizes ranging from 512 bits to 8192 bits. success = rsa.GenerateKey(2048); if (success != true) { strOut.append(rsa.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkPrivateKey *privKey = rsa.ExportPrivateKeyObj(); // Get the private key in PKCS8 Base64 format const char *privKeyPkcs8Base64 = privKey->getPkcs8ENC("base64"); // The key in base64 format will start similar to this: // MIIEvAIBADANBgkqhkiG9w0BA... strOut.append(privKeyPkcs8Base64); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.