我有最基本的 Turbo LockBox 2 代码,它尝试加载使用 https://travistidwell.com/jsencrypt/demo/生成的公共 RSA 密钥
这是单位:
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.
这是最基本的组件:
object LbRSA: TLbRSA
PrimeTestIterations = 20
KeySize = aks512
Left = 184
Top = 56
end
如何克服“无效的 RSA 密钥”错误消息?也许我的源代码不是 UTF8 格式,这就是为什么 skeypub 字符串不是有效的 Unicode 字符串?