DelphiCryptlib is an objectoriented wrapper for the functions defined in cryptlib.pas and some additional useful high level functionalities. This interface is more "Delphi-like" than cryptlib.pas, which is "C-like".
DelphiCryptlib now comes with a detailed Helpfile that is compatible with the Delphi IDE.
DelphiCryptlib.hlp may be installed in the Delphi Help system. You may use the "F1"-key when editing your source to popup online help on any DelphiCryptlib object, method or property.
I'm sorry, the helpfile was not updated since 2005. Some entries may be outdated.
The essential objects defined in DelphiCryptlib.pas are:
All standard error handling from cryptlib is done via Exception handling in Delphi. You don't have to check the return codes after every cryptlib call.
Most cryptlib attributes are defined as properties in DelphiCryptlib. If Cert is a TCryptCert variable, you may use:
|
|
---|---|
if Cert.isSelfSigned then ... |
ask, if certificate Cert has attribute CRYPT_CERTINFO_SELFSIGNED |
name := Cert.CommonName; |
extract attribute CRYPT_CERTINFO_COMMONNAME from certificate Cert and assign it as string to name. |
if Cert.NextCert then ... |
set internal cursor to next certificate (if any) in a certificate chain |
As example for the usage of DelphiCryptlib here is a code snippet which encodes a file "MyTestfile.txt" conventionally using the Rijndael algorithm (AES) with password "MyPassword" to a new file named "EncodedFile.bin" :
var InputData, OutputData: TStream; Encrypt: TCryptEnvelope; begin InputData := TFileStream.Create('MyTestfile.txt', fmOpenRead); { open input file } OutputData := TFileStream.Create('EncodedFile.bin', fmCreate); { open output file } Encrypt := TCryptEnvelope.Create(CRYPT_FORMAT_SMIME); { create encryption object } Encrypt.Password := 'MyPassword'; { set password for encryption } Encrypt.SetAttribute(CRYPT_OPTION_ENCR_ALGO, CRYPT_ALGO_AES); { set algorithm to AES } Encrypt.StreamIO(InputData, OutputData); { do the encryption } Encrypt.Free; { delete all objects used } InputData.Free; { close inputfile } OutputData.Free; { clode outputfile } end;I had several requests for Delphi examples using cryptlib. And because I'm tired to send my sample code via mail on request, I decided to put some examples on my homepage.
A Helpfile is available for DelphiCryptlib, but you should have read Peter Gutman's cryptlib manual before. For details of the implementation have a look into the interface part of the DelphiCryptlib.pas and the samples source.
Download for cryptlib version 3.4.3 :
And you know, if you download the source, you do it on your own risk. I can't give you any support and any warranties are explicitly disclaimed.
Please use this with the latest CL32.DLL or CL64.DLL version 3.4.3 only, other cryptlib versions are no longer supported !
Cryptlib V3.4.3
(dated 2016-03-25)Files Comment cryptlib.pas
Delphi interface file generated from cryptlib.h
DelphiCryptlib.pas
Cryptlib interface file for Delphi programmers.
CL32.DLL
CL64.DLLPeter Gutman's Cryptlib binaries version 3.4.3
cl343.zip
Peter Gutman's Cryptlib version 3.4.3 binaries and source files
manual.pdf
Peter Gutman's cryptlib manual for version 3.4.3
install.txt
DelphiCryptlib.hlp
DelphiCryptlib.cntHelpfile for DelphiCryptlib, installable in Delphi IDE (see install.txt)
Look for sample code showing how to use Cryptlib.pas
Please report problems and errors to problems@cryptlib.sogot.de
If you find this useful (and if you use DelphiCryptlib.pas in your programs) please mail me a message to delphi@cryptlib.sogot.de!Cryptlib pages by Wolfgang Gothier | Last changes:2016-11-30 |