Download source code
This sample cryptographically encrypts / decrypts files with digital x509 certificate.
procedure TForm1.btnEncryptClick(Sender: TObject);
var
dlg: TGetCertDialog;
begin
dlg := TGetCertDialog.Create(nil);
try
dlg.Caption := 'Get encryption certificate';
if (dlg.ShowModal() = mrOK) then
begin
clEncryptor1.EncryptStore := dlg.edtStore.Text;
clEncryptor1.EncryptCertificate := dlg.edtEmail.Text;
end;
finally
dlg.Free();
end;
clEncryptor1.Encrypt(edtSource.Text, edtDestination.Text);
ShowMessage(Format('The file %s was encrypted and stored to %s', [edtSource.Text, edtDestination.Text]));
end;
procedure TForm1.btnDecryptClick(Sender: TObject);
var
dlg: TGetCertDialog;
begin
dlg := TGetCertDialog.Create(nil);
try
dlg.Caption := 'Get encryption certificate';
if (dlg.ShowModal() = mrOK) then
begin
clEncryptor1.EncryptStore := dlg.edtStore.Text;
clEncryptor1.EncryptCertificate := dlg.edtEmail.Text;
end;
finally
dlg.Free();
end;
clEncryptor1.Decrypt(edtSource.Text, edtDestination.Text);
ShowMessage(Format('The file %s was decrypted and stored to %s', [edtSource.Text, edtDestination.Text]));
end;
Article ID: 95, Created: November 24, 2017 at 12:32 PM, Modified: November 19, 2019 at 8:02 PM