DCPcrypt Cryptographic Component Library v2.0.6

February 11, 2026 · View on GitHub

Lazarus / Free Pascal edition Originally written by David Barton

Introduction

DCPcrypt is a collection of cryptographic components originally written for Borland Delphi by David Barton, ported to Lazarus/Free Pascal and maintained by multiple contributors.

The idea behind DCPcrypt is that it should be possible to "drop in" any algorithm implementation to replace another with minimum or no code changes. To aid in this goal all cryptographic components are descended from one of several base classes, TDCP_cipher for encryption algorithms and TDCP_hash for message digest algorithms.

DCPcrypt is open source software released under the MIT license. There is no charge for inclusion in other software.

This software is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source Initiative.

What's New

Changes in v2.0.6 by Nicolas Deoux (2026):

  • Added console demo: demo_hash_large_file - Large file hashing (>5 GB) with real-time progress, manual Hash.Update() loop with 64 KB blocks, --size=N and --dir=path options
  • Added {$MODE Delphi} to dcpbase64.pas and dcpconst.pas (all units now have explicit mode directives)
  • Switched all examples (console + GUI) to {$MODE ObjFPC}{$H+} (no -Mdelphi flag needed)

Changes in v2.0.5 by Nicolas Deoux (2026):

  • Added GUI examples ported from Delphi VCL to Lazarus LCL:
    • EncryptStrings - String encryption/decryption using EncryptStream
    • FileEncrypt - File encryption/decryption with thread support
  • Added functional test suite (282 tests) with Makefile
  • Added GitHub Actions CI/CD pipeline (Linux, Windows, macOS)
  • Added console demo examples (string and file encryption)

Changes in v2.0.4.2 by Werner Pamler (2022):

  • Fix hashes for files >4 GB (issue #31934)

Changes in v2.0.4.1 by Graeme Geldenhuys (2010):

  • More fixes for 64-bit support
  • Removed a lot of compiler warnings - tested with FPC 2.4.1

Changes in v2.0.4 by Graeme Geldenhuys (2009):

  • Split the Lazarus package into two separate packages (runtime and design-time)
  • Updated code to be compilable with FPC 2.4.0-rc1
  • Updated code to be compilable with 64-bit FPC 2.4.0-rc1

Ported to Lazarus by Barko in 2006.

Installation

Option 1 - PackagesOpen src/dcpcrypt.lpk (runtime) and src/dcpcrypt_laz.lpk (design-time) in the Lazarus IDE and install them. Cipher and hash components will appear on the component palette.
Option 2 - Direct useAdd src/, src/Ciphers/ and src/Hashes/ to your project unit search paths. Create cipher and hash instances in code. See the GUI examples.

Examples

Console examplesexamples/console/ - String/file encryption, file hashing demos
GUI examplesexamples/gui/EncryptStrings/ - String encryption with EncryptStream
examples/gui/FileEncrypt/ - File encryption with thread support
Build with: lazbuild <project>.lpi

Testing

A functional test suite is provided in tests/. It requires only Free Pascal (fpc) and no IDE.

make test             # build and run all tests
make build-examples   # compile all examples (console + GUI)
make build-all        # compile everything (tests + examples)
make check            # clean, build and run (full verification)
make clean            # remove compiled binaries and objects
make info             # show project information

The suite contains 5 test programs (282 individual checks):

ProgramCoverage
test_hashesSelfTest, digest correctness, determinism, Burn for all 10 hashes
test_ciphersSelfTest, encrypt/decrypt roundtrip, Burn, properties for all 20 ciphers
test_block_modesECB, CBC, CFB8bit, CFBblock, OFB, CTR for Rijndael (128-bit) and Blowfish (64-bit)
test_base64Encode/decode roundtrips, RFC 4648 known values, binary data
test_stream_encryptSalt+IV stream encryption, empty/long strings, PartialEncryptStream, OnProgressEvent

CI/CD

A GitHub Actions pipeline is provided in .github/workflows/ci.yml. It runs automatically on push and pull requests.

StagePlatformsPurpose
build-and-testLinux, Windows, macOSCompile and run all 282 tests
build-examplesLinux, Windows, macOSVerify console and GUI examples compile
releaseLinuxCreate GitHub release (on v* tags only)

See .github/workflows/README.md for details.

Usage

Please note that an appreciation of the basic principles of encryption/decryption and key management is needed to ensure the correct usage of the ciphers implemented within this package. A good introduction on this subject is provided by Bruce Schneier's "Applied Cryptography" (ISBN: 0-471-11709-9) also see the NIST publication SP800-38A for information on the block cipher chaining modes.

  • Ciphers - the basic building block of DCPcrypt, the TDCP_cipher component.
  • Block Ciphers - the base of all block ciphers, the TDCP_blockcipher component.
  • Hashes - the base of all hash algorithms, the TDCP_hash component.

DCPcrypt contains the following ciphers and hash algorithms:

Ciphers

NamePatentsBlock SizeMax Key Size*
BlowfishNone64 bits448 bits
Cast128None64 bits128 bits
Cast256Patented?128 bits256 bits
DESNone64 bits64 bits**
3DESNone64 bits192 bits
IceNone?64 bits64 bits
Thin IceNone?64 bits64 bits
Ice2None?64 bits128 bits
GostNone64 bits256 bits
IDEAFree for non-commercial use64 bits128 bits
MARSPatented?128 bits1248 bits
Misty1Free for non-commercial use64 bits128 bits
RC2None64 bits1024 bits
RC4NoneN/A2048 bits
RC5Patented64 bits2048 bits
RC6Patented128 bits2048 bits
Rijndael (AES)None128 bits256 bits
SerpentNone128 bits256 bits
TEANone64 bits128 bits
TwofishNone128 bits256 bits

* Although the quoted maximum key size may be extremely large it doesn't mean that the algorithm is secure to the same level.

** A 64bit key is used for DES then every 8th bit is discarded (parity) so the effective size is 56 bits.

Hash Algorithms

NamePatentsDigest Size
HavalNone128, 160, 192, 224, 256 bits*
MD4None128 bits
MD5None128 bits
RipeMD-128None128 bits
RipeMD-160None160 bits
SHA1None160 bits
SHA256None256 bits
SHA384None384 bits
SHA512None512 bits
TigerNone192 bits

* The different digest sizes of Haval can be accessed by uncommenting the $defines at the start of DCPhaval.pas.

See Also

Contributors

NameContribution
David BartonOriginal DCPcrypt author (1999-2003)
BarkoLazarus port (2006)
Graeme GeldenhuysPackage split, 64-bit support (2009-2010)
Werner PamlerLarge file hash fix (2022)
Nicolas DeouxGUI examples VCL→LCL port, console demos, large-file hashing demo, test suite, Makefile, docs (2026) - NDXDev@gmail.com

DCPcrypt is copyrighted by its respective authors. Released under the MIT license. All trademarks are property of their respective owners.