Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Load PEM Public/Private Key into RSA ObjectDemonstrates how to load a PEM key into the Chilkat RSA object. Download: Chilkat .NET Assemblies Chilkat.Rsa rsa = new Chilkat.Rsa(); bool success; success = rsa.UnlockComponent("Anything for 30-day trial"); if (success != true) { textBox1.Text += rsa.LastErrorText + "\r\n"; return; } // First demonstrate importing a PEM public key: string publicKeyPem; publicKeyPem = "PEM public-key data goes here"; Chilkat.PublicKey pubkey = new Chilkat.PublicKey(); success = pubkey.LoadOpenSslPem(publicKeyPem); if (success != true) { textBox1.Text += pubkey.LastErrorText + "\r\n"; return; } string publicKeyXml; publicKeyXml = pubkey.GetXml(); success = rsa.ImportPublicKey(publicKeyXml); if (success != true) { textBox1.Text += rsa.LastErrorText + "\r\n"; return; } // Demonstrate importing a PEM private key: string privateKeyPem; privateKeyPem = "PEM private-key data goes here"; Chilkat.PrivateKey privkey = new Chilkat.PrivateKey(); // If the private key PEM is protected with a password, then // call LoadEncryptedPem. Otherwise call LoadPem. success = privkey.LoadPem(privateKeyPem); if (success != true) { textBox1.Text += privkey.LastErrorText + "\r\n"; return; } string privateKeyXml; privateKeyXml = privkey.GetXml(); success = rsa.ImportPrivateKey(privateKeyXml); if (success != true) { textBox1.Text += rsa.LastErrorText + "\r\n"; return; } MessageBox.Show("OK!"); |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.