Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi ActiveX) Generate an RSA Key and Export to XMLSee more RSA ExamplesDemonstrates how to generate an RSA key and export public/private to XML.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB; ... procedure TForm1.Button1Click(Sender: TObject); var rsa: TChilkatRsa; success: Integer; privKeyXml: WideString; pubKeyXml: WideString; begin rsa := TChilkatRsa.Create(Self); // Generate a 2048-bit key. success := rsa.GenerateKey(2048); if (success = 0) then begin Memo1.Lines.Add(rsa.LastErrorText); Exit; end; privKeyXml := rsa.ExportPrivateKey(); Memo1.Lines.Add(privKeyXml); // Sample output: // <RSAKeyValue> // <Modulus>pvxYRzbV8Gru5/NNFQunXkLfhUW9W83/A+LtVD5jhV5oDZ5mv9R3BbfBE88UTqGjA1jZoFegprY3dGpm7Dl0PFqIYSwfE869Tx7OGzg+ocsM3klTBslxVftN4grJzovfWeUbi22JNbOEjuvI9548OmTnIHhYI9yhl54xyIHUIRWCa6nlPNfqqFD/tscmel+2AwWM5hhylse2Q3xg1Y3D3al3BckGGvrBGjKAFoN60+kmD0mnisy0zfHRAiHH8EsqSXASXjqRa6G60jj+tRrdY5AcOrtWe7tsoHE8txGI+xZQ6g3MWelyNM6Dnb324hid8rNxj33lFiqbOkQGPvE9fw==</Modulus> // <Exponent>AQAB</Exponent> // <D>fsydqC3+lJpOoblBrhp0VAKJwqSrXpv06pmVx+O8JJkEgFrpAP+wBZp8NbOIYxEgPLlqP/RqXE1/nJnzX6tdFTtV1hvv2VWisQLeVRMHlEogkmaxcjTjJ/w1LtEsXvgdeSCdIunhR/LyV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obrxd1rpBi2jTIFESgD0Cn5CKEIUpXIGntaNLLgDI=</InverseQ> // </RSAKeyValue> pubKeyXml := rsa.ExportPublicKey(); Memo1.Lines.Add(pubKeyXml); // Sample output: // <RSAPublicKey> // <Modulus>pvxYRzbV8Gru5/NNFQunXkLfhUW9W83/A+LtVD5jhV5oDZ5mv9R3BbfBE88UTqGjA1jZoFegprY3dGpm7Dl0PFqIYSwfE869Tx7OGzg+ocsM3klTBslxVftN4grJzovfWeUbi22JNbOEjuvI9548OmTnIHhYI9yhl54xyIHUIRWCa6nlPNfqqFD/tscmel+2AwWM5hhylse2Q3xg1Y3D3al3BckGGvrBGjKAFoN60+kmD0mnisy0zfHRAiHH8EsqSXASXjqRa6G60jj+tRrdY5AcOrtWe7tsoHE8txGI+xZQ6g3MWelyNM6Dnb324hid8rNxj33lFiqbOkQGPvE9fw==</Modulus> // <Exponent>AQAB</Exponent> // </RSAPublicKey> end; |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.