Delphi Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
DH Key Exchange
DSA
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
NTLM
POP3
RSA
S/MIME
SMTP
Socket
Spider
SFTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Byte Array
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

Type Conversion

 

Article: Understanding COM References in Delphi

Public Key Encryption using PKCS7 File Format

Download Chilkat Crypt ActiveX

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.

Mail Component · .NET Email Component · XML Parser