procedure TForm53.Button2Click(Sender: TObject);
var
base64String :
String;
InputStr :
String;
OutputStr :
String;
tmp : TStream;
PubKeys : TMemoryStream;
Privkeys : TMemoryStream;
begin
PubKeys := TMemoryStream.Create;
PrivKeys := TMemoryStream.Create;
Memo1.Lines.Append('
Loading Keys from DB');
fdquery.SQL.Text := '
SELECT jk_data FROM justkeys where jk_uid = 7';
fdquery.Open;
fdquery.first;
tmp := fdquery.CreateBlobStream(fdquery.FieldByName('
jk_data'),TBlobStreamMode.bmRead);
PubKeys.LoadFromStream(tmp);
tmp.Free;
fdquery.Close;
fdquery.SQL.Text := '
SELECT jk_data FROM justkeys where jk_uid = 8';
fdquery.open;
fdquery.First;
tmp := fdquery.CreateBlobStream(fdquery.FieldByName('
jk_data'),TBlobStreamMode.bmRead);
PrivKeys.LoadFromStream(tmp);
tmp.Free;
fdquery.Close;
Memo1.Lines.Append('
Keys Loaded !');
Pubkeys.Seek(0,soBeginning);
Privkeys.Seek(0,soBeginning);
Signatory1.LoadKeysFromStream(pubkeys,[partPublic]);
Signatory1.LoadKeysFromStream(privkeys,[partPrivate]);
InputStr := '
Das ist ein sehr schöner Text zum testen der verschlüsselung';
codecRSA.EncryptString(InputStr,base64String,TEncoding.Unicode);
memo1.Lines.Append('
Encryption: ');
memo1.Lines.Append('
Plaintext: '+InputStr);
memo1.Lines.Append('
Encrypted (Base64)');
memo1.Lines.Append(base64String);
memo1.Lines.Append('
');
codecRSA.DecryptString(OutputStr,base64String,TEncoding.Unicode);
memo1.Lines.Append('
Decrypted:');
memo1.Lines.Append(outputStr);
Pubkeys.Free;
privkeys.Free;
end;