Cryptographic Component Library for Free Pascal/Lazarus
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. All cryptographic components are descended from one of several base classes: TDCP_cipher for encryption algorithms and TDCP_hash for message digest algorithms.
- 20 Cipher Algorithms - Rijndael (AES), Blowfish, Twofish, Serpent, DES, 3DES, RC4, and more
- 10 Hash Algorithms - SHA-1, SHA-256, SHA-384, SHA-512, MD5, RipeMD-160, Tiger, and more
- 6 Block Cipher Modes - ECB, CBC, CFB8bit, CFBblock, OFB, CTR
- Stream Encryption - Salt+IV EncryptStream/DecryptStream with progress callbacks
- Base64 - Encoding and decoding
- Cross-Platform - Linux, Windows, and macOS support
- No External Dependencies - Pure Pascal implementation
String Encryption — Encrypt/decrypt strings with any cipher+hash combination:
| Initial state | After encryption |
|---|---|
![]() |
![]() |
File Encryption — Encrypt/decrypt files with progress bar (threaded):
| Ready to encrypt | Encryption in progress |
|---|---|
![]() |
![]() |
Option 1 - Packages (IDE)
Open src/dcpcrypt.lpk (runtime) and src/dcpcrypt_laz.lpk (design-time) in the Lazarus IDE. Cipher and hash components will appear on the component palette.
Option 2 - Direct use (no IDE)
Add the source paths to your project:
-Fupath/to/dcpcrypt-lazarus/src -Fupath/to/dcpcrypt-lazarus/src/Ciphers -Fupath/to/dcpcrypt-lazarus/src/Hashes
program QuickDemo;
{$MODE ObjFPC}{$H+}
uses
DCPrijndael, DCPsha256, DCPcrypt2;
var
Cipher: TDCP_rijndael;
Encrypted, Decrypted: string;
begin
Cipher := TDCP_rijndael.Create(nil);
try
// Initialize with a passphrase (hashed with SHA-256)
Cipher.InitStr('my secret passphrase', TDCP_sha256);
// Encrypt a string (result is Base64-encoded)
Encrypted := Cipher.EncryptString('Hello World');
WriteLn('Encrypted: ', Encrypted);
// Decrypt
Cipher.Reset;
Decrypted := Cipher.DecryptString(Encrypted);
WriteLn('Decrypted: ', Decrypted);
Cipher.Burn;
finally
Cipher.Free;
end;
end.Compile with:
fpc -Fusrc -Fusrc/Ciphers -Fusrc/Hashes quickdemo.lpr| Name | Block Size | Max Key Size |
|---|---|---|
| Rijndael (AES) | 128 bits | 256 bits |
| Blowfish | 64 bits | 448 bits |
| Twofish | 128 bits | 256 bits |
| Serpent | 128 bits | 256 bits |
| Cast128 | 64 bits | 128 bits |
| Cast256 | 128 bits | 256 bits |
| DES | 64 bits | 64 bits |
| 3DES | 64 bits | 192 bits |
| RC2 | 64 bits | 1024 bits |
| RC4 | N/A (stream) | 2048 bits |
| RC5 | 64 bits | 2048 bits |
| RC6 | 128 bits | 2048 bits |
| MARS | 128 bits | 1248 bits |
| IDEA | 64 bits | 128 bits |
| Misty1 | 64 bits | 128 bits |
| Ice / Thin Ice / Ice2 | 64 bits | 64-128 bits |
| Gost | 64 bits | 256 bits |
| TEA | 64 bits | 128 bits |
| Name | Digest Size |
|---|---|
| SHA-1 | 160 bits |
| SHA-256 | 256 bits |
| SHA-384 | 384 bits |
| SHA-512 | 512 bits |
| MD4 | 128 bits |
| MD5 | 128 bits |
| RipeMD-128 | 128 bits |
| RipeMD-160 | 160 bits |
| Haval | 128-256 bits |
| Tiger | 192 bits |
| Document | Description |
|---|---|
| Full Documentation | Detailed project documentation |
| Ciphers API | TDCP_cipher reference |
| Block Ciphers API | TDCP_blockcipher reference |
| Hashes API | TDCP_hash reference |
| Changelog | Version history |
| Building | Compilation instructions |
| Table of Contents | Full documentation index |
| Example | Description |
|---|---|
demo_encrypt_string |
Salt+IV string encryption/decryption |
demo_file_encrypt |
File encryption with progress callback |
demo_hash_file |
Hash files using all 10 hash algorithms |
demo_hash_large_file |
Hash large files (>5 GB) with real-time progress (--size=N, --dir=path) |
cd examples/console
fpc -Fusrc -Fusrc/Ciphers -Fusrc/Hashes demo_encrypt_string.lpr
./demo_encrypt_string| Example | Description |
|---|---|
EncryptStrings |
String encryption/decryption using EncryptStream |
FileEncrypt |
File encryption/decryption with thread support |
lazbuild examples/gui/EncryptStrings/EncryptStringsViaEncryptStream.lpiA functional test suite (282 tests) is provided in tests/. It requires only 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)| Program | Tests | Coverage |
|---|---|---|
test_hashes |
90 | SelfTest, digest, determinism, Burn for 10 hashes |
test_ciphers |
139 | SelfTest, roundtrip, Burn, properties for 20 ciphers |
test_block_modes |
28 | ECB, CBC, CFB8bit, CFBblock, OFB, CTR |
test_base64 |
11 | RFC 4648, binary data, edge cases |
test_stream_encrypt |
14 | Salt+IV, PartialEncryptStream, OnProgressEvent |
- Compiler: Free Pascal 3.2.0 or later
- IDE: Lazarus 2.0+ (optional, for GUI examples and packages)
- Dependencies: None (pure Pascal)
dcpcrypt-lazarus/
├── src/ # Source code
│ ├── Ciphers/ # 17 cipher units
│ ├── Hashes/ # 9 hash units
│ ├── Docs/ # Original HTML docs and license
│ ├── dcpcrypt2.pas # Base classes (TDCP_cipher, TDCP_hash)
│ ├── dcpblockciphers.pas # Block cipher modes
│ ├── dcpbase64.pas # Base64 encoding/decoding
│ ├── dcpcrypt.lpk # Runtime package
│ └── dcpcrypt_laz.lpk # Design-time package
├── tests/ # Functional test suite (282 tests)
├── examples/ # Console and GUI examples
│ ├── console/ # 4 console demos
│ └── gui/ # 2 GUI examples (LCL)
├── docs/ # Markdown documentation
├── .github/workflows/ # CI/CD configuration
└── Makefile # Build, test, clean targets
| Platform | Architecture | Status |
|---|---|---|
| Linux | x86_64, aarch64 | Supported |
| Windows | x86, x64 | Supported |
| macOS | Intel, Apple Silicon | Supported |
| Linux Snap | x86_64 | Supported |
| Linux Flatpak | x86_64 | Supported |
Contributions are welcome. Please ensure:
- Code compiles without warnings
- All 282 tests pass (
make test) - Examples compile correctly
- Documentation is updated
See CONTRIBUTING.md for details.
MIT License - See LICENSE for details.
| Name | Contribution |
|---|---|
| David Barton | Original DCPcrypt author (1999-2003) |
| Barko | Lazarus port (2006) |
| Graeme Geldenhuys | Package split, 64-bit support (2009-2010) |
| Werner Pamler | Large file hash fix (2022) |
| Nicolas Deoux | GUI examples VCL-to-LCL port, console demos, large-file hashing demo, test suite, Makefile, CI/CD, docs (2026) |
Nicolas DEOUX
DCPcrypt is copyrighted by its respective authors. Released under the MIT license. All trademarks are property of their respective owners.



