DCPcrypt

February 11, 2026 · View on GitHub

Cryptographic Component Library for Free Pascal/Lazarus

CI License: MIT Free Pascal Platform


Overview

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.

Key Features

  • 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

Screenshots

String Encryption — Encrypt/decrypt strings with any cipher+hash combination:

Initial stateAfter encryption
EncryptStrings - initialEncryptStrings - encrypted

File Encryption — Encrypt/decrypt files with progress bar (threaded):

Ready to encryptEncryption in progress
FileEncrypt - readyFileEncrypt - progress

Quick Start

Installation

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

Basic Usage

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

Algorithms

Ciphers

NameBlock SizeMax Key Size
Rijndael (AES)128 bits256 bits
Blowfish64 bits448 bits
Twofish128 bits256 bits
Serpent128 bits256 bits
Cast12864 bits128 bits
Cast256128 bits256 bits
DES64 bits64 bits
3DES64 bits192 bits
RC264 bits1024 bits
RC4N/A (stream)2048 bits
RC564 bits2048 bits
RC6128 bits2048 bits
MARS128 bits1248 bits
IDEA64 bits128 bits
Misty164 bits128 bits
Ice / Thin Ice / Ice264 bits64-128 bits
Gost64 bits256 bits
TEA64 bits128 bits

Hash Algorithms

NameDigest Size
SHA-1160 bits
SHA-256256 bits
SHA-384384 bits
SHA-512512 bits
MD4128 bits
MD5128 bits
RipeMD-128128 bits
RipeMD-160160 bits
Haval128-256 bits
Tiger192 bits

Documentation

DocumentDescription
Full DocumentationDetailed project documentation
Ciphers APITDCP_cipher reference
Block Ciphers APITDCP_blockcipher reference
Hashes APITDCP_hash reference
ChangelogVersion history
BuildingCompilation instructions
Table of ContentsFull documentation index

Examples

Console

ExampleDescription
demo_encrypt_stringSalt+IV string encryption/decryption
demo_file_encryptFile encryption with progress callback
demo_hash_fileHash files using all 10 hash algorithms
demo_hash_large_fileHash 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

GUI (Lazarus LCL)

ExampleDescription
EncryptStringsString encryption/decryption using EncryptStream
FileEncryptFile encryption/decryption with thread support
lazbuild examples/gui/EncryptStrings/EncryptStringsViaEncryptStream.lpi

Testing

A 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)
ProgramTestsCoverage
test_hashes90SelfTest, digest, determinism, Burn for 10 hashes
test_ciphers139SelfTest, roundtrip, Burn, properties for 20 ciphers
test_block_modes28ECB, CBC, CFB8bit, CFBblock, OFB, CTR
test_base6411RFC 4648, binary data, edge cases
test_stream_encrypt14Salt+IV, PartialEncryptStream, OnProgressEvent

Requirements

  • Compiler: Free Pascal 3.2.0 or later
  • IDE: Lazarus 2.0+ (optional, for GUI examples and packages)
  • Dependencies: None (pure Pascal)

Project Structure

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 Support

PlatformArchitectureStatus
Linuxx86_64, aarch64Supported
Windowsx86, x64Supported
macOSIntel, Apple SiliconSupported
Linux Snapx86_64Supported
Linux Flatpakx86_64Supported

Contributing

Contributions are welcome. Please ensure:

  1. Code compiles without warnings
  2. All 282 tests pass (make test)
  3. Examples compile correctly
  4. Documentation is updated

See CONTRIBUTING.md for details.


License

MIT License - See LICENSE for details.


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-to-LCL port, console demos, large-file hashing demo, test suite, Makefile, CI/CD, docs (2026)

Author (v2.0.6)

Nicolas DEOUX


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


Star on GitHub Follow

Back to top

Last updated: February 2026 | FPC 3.2.0+