Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Public Key Encryption using PKCS7 File Format
Delphi example program to encrypt a file using a digital certificate. The output is a .p7b (PKCS#7) file format. procedure TForm1.Button2Click(Sender: TObject); var certStore: CHILKATCERTIFICATELib_TLB.IChilkatCertStore; cert: CHILKATCERTIFICATELib_TLB.IChilkatCert; success: Integer; begin // This example public-key encrypts a file using the PKCS#7 format. // ChilkatCrypt21 is an instance of ChilkatCrypt2 // that we dropped onto our form. ChilkatCrypt21.UnlockComponent('anything for 30-day trial'); // Set the algorithm to "pki" which indicates public-key encryption // where a digital certificate is to be used. ChilkatCrypt21.CryptAlgorithm := 'pki'; // We need a digital certificate... // The ChilkatCreateCS1 is an instance of the ChilkatCreateCS object // dropped onto the Delphi form. It is used to open a certificate // store where we'll search for our certificate. certStore := ChilkatCreateCS1.OpenLocalSystemStore(); if (certStore <> nil) then begin cert := certStore.FindCertBySubjectE('admin@chilkatsoft.com'); if (cert <> nil) then begin ChilkatCrypt21.SetEncryptCert(cert as CHILKATCRYPT2Lib_TLB.IChilkatCert); success := ChilkatCrypt21.CkEncryptFile('halfMarathon.pdf','halfMarathon.p7b'); if (success = 1) then begin ShowMessage('Encryption successful!'); end else ShowMessage(ChilkatCrypt21.LastErrorText); end else begin ShowMessage('Failed to find certificate!'); end; end else begin ShowMessage(ChilkatCreateCS1.LastErrorText); end; end;
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.