I have the most basic Turbo LockBox 2 code that tries to load public RSA key that is generated with https://travistidwell.com/jsencrypt/demo/
Here is the unit:
unit MainFormU;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, LbCipher, LbClass, LbAsym, LbRSA,
Vcl.StdCtrls;
type
TMainForm = class(TForm)
LbRSA: TLbRSA;
LoadBtn: TButton;
procedure LoadBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
const
//skeypub=string('MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALPllOJsy3XNdicjBHT2MaxT7q74/vcKcWfZG4SBiJY0KGtbavsMpntgFPeqdQ4mDUEwpU6aWX7E3dXopRx9kXECAwEAAQ==');
skeypub=string(
'-----BEGIN PUBLIC KEY-----'+
'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALPllOJsy3XNdicjBHT2MaxT7q74/vcK'+
'cWfZG4SBiJY0KGtbavsMpntgFPeqdQ4mDUEwpU6aWX7E3dXopRx9kXECAwEAAQ=='+
'-----END PUBLIC KEY-----');
{
skeyprv='MIIBOgIBAAJBALPllOJsy3XNdicjBHT2MaxT7q74/vcKcWfZG4SBiJY0KGtbavsM'+
'pntgFPeqdQ4mDUEwpU6aWX7E3dXopRx9kXECAwEAAQJATvKtASVPsPYnKQvEE/RL'+
'Xl5DPESH2DCcDkAIRIF4SLoCGHLu2cbi2YKpLJSNk34QdH4Vt1itadRIQu2SIs1G'+
'AQIhAP2hKduEbtsZHgRDqMHYMEhKglbhbPaZ/AR3qg2oKbthAiEAtZQBILGWZGfB'+
'GjB9Hn5RqcZxHpI4MbYjLxdb4AnMIBECIAzAcJlP1D8ByUePm0l7tBm+XUU++jp/'+
'zXLwDUW4gbihAiEAsrA6A+B/rcNlBs7c8ltBJiBBReKDJnilWzxTj8BUfuECIBWY'+
'nQUs9nKCzJAdoxmuTwH18odUlinGYGj2BNlPJ+dP'; }
procedure TMainForm.LoadBtnClick(Sender: TObject);
var S: TStringStream;
begin
S:=TStringStream.Create(skeypub);
LbRSA.PublicKey.LoadFromStream(S);
end;
end.
and here is the most basic component:
object LbRSA: TLbRSA
PrimeTestIterations = 20
KeySize = aks512
Left = 184
Top = 56
end
How to overcome 'Invalid RSA key' error message? Maybe my source code is not UTF8 formatted and that is why the skeypub string is not the valid Unicode string?