Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

mORMot2-Cryptography-Demo

mORMot2 Comprehensive Cryptography Demo For Delphi!

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

mORMot V2 Cryptography Demonstration Utility

This comprehensive Delphi application showcases the powerful cryptographic capabilities of the mORMot V2 framework. It provides a professional-grade interface for encryption/decryption, hashing, message authentication, key derivation, and secure random number generation.

Screenshot of the mORMot V2 Cryptography Utility

⚠️ Security Notice

This tool is designed for educational and demonstration purposes. While it implements industry-standard cryptographic algorithms, always review and adapt the code for production use. Pay special attention to key management, salt generation, and iteration counts for PBKDF2.

Features

  • AES Encryption Modes: Support for ECB, CBC, CFB, OFB, CTR, GCM, and mORMot custom AEAD modes (CFC, OFC, CTC).
  • Variable Key Sizes: 128-bit, 192-bit, and 256-bit AES encryption support.
  • Multiple Hash Algorithms: MD5, SHA-1, SHA-256, SHA-384, SHA-512, SHA-3-256, and SHA-3-512.
  • HMAC Authentication: HMAC-SHA256 for message authentication and integrity verification.
  • PBKDF2 Key Derivation: Password-based key derivation with configurable iterations.
  • Secure Random Generation: Cryptographically secure random number generation using TAesPrng.
  • Flexible Output Encoding: Base64 or Hexadecimal output formats.
  • Performance Metrics: Real-time encryption/decryption speed and throughput measurements.
  • Professional Documentation: Extensively commented code with security best practices.
## Installation 1. **Install mORMot V2 Framework:** - Download the latest mORMot V2 from [GitHub](https://github.com/synopse/mORMot2). - Extract the framework to your desired location. - Update the Library Path: - Go to **Tools -> Options...** and select **Library Path** for Win32/Win64. - Add the path to the mORMot2 `src` directory and its subdirectories: - `[mORMot2_Path]\src\core` - `[mORMot2_Path]\src\crypt` - `[mORMot2_Path]\src\net` - `[mORMot2_Path]\src\db` 2. **Open Delphi Project:** Open the `.dpr` file in the Delphi IDE. 3. **Compile:** Build the project to generate the executable. 4. **Run:** Execute the utility to start exploring cryptographic functions.

Usage

Encryption/Decryption

  1. Select Mode: Choose from various AES encryption modes (CBC recommended for general use).
  2. Set Key Size: Select 128, 192, or 256-bit encryption (256-bit recommended).
  3. Enter Password: Provide a strong password for key derivation.
  4. Configure Options: Enable random IV and choose output encoding.
  5. Encrypt/Decrypt: Enter text and perform encryption or decryption operations.

Hash Functions

  1. Select Algorithm: Choose from MD5, SHA variants, or SHA-3 (SHA-256 recommended).
  2. Enter Text: Input the text to be hashed.
  3. Calculate: Generate the cryptographic hash.

HMAC Authentication

  1. Set Key: Enter a secret key for HMAC calculation.
  2. Enter Message: Input the message to authenticate.
  3. Generate HMAC: Calculate HMAC-SHA256 for verification.

Key Derivation (PBKDF2)

  1. Enter Password: Provide the source password.
  2. Set Salt: Enter cryptographic salt (use random salt in production).
  3. Configure Iterations: Set iteration count (minimum 10,000 recommended).
  4. Derive Key: Generate the strengthened key.

Random Generation

  1. Specify Length: Enter desired number of random bytes (1-1024).
  2. Generate: Create cryptographically secure random data.

Supported Algorithms

Encryption Modes

  • AES-ECB: Electronic Codebook (⚠️ NOT RECOMMENDED for production)
  • AES-CBC: Cipher Block Chaining (widely supported)
  • AES-CFB: Cipher Feedback (stream mode)
  • AES-OFB: Output Feedback (stream mode)
  • AES-CTR: Counter Mode (fast, parallelizable)
  • AES-GCM: Galois/Counter Mode (AEAD - authenticated encryption)
  • AES-CFC: mORMot CFB + CRC32C (custom AEAD)
  • AES-OFC: mORMot OFB + CRC32C (custom AEAD)
  • AES-CTC: mORMot CTR + CRC32C (custom AEAD)

Hash Functions

  • MD5: 128-bit (⚠️ cryptographically broken)
  • SHA-1: 160-bit (⚠️ deprecated for security)
  • SHA-256: 256-bit (✅ recommended)
  • SHA-384: 384-bit (high security)
  • SHA-512: 512-bit (high security)
  • SHA-3-256: 256-bit (latest standard)
  • SHA-3-512: 512-bit (latest standard, high security)

Security Best Practices

  • Use Strong Passwords: Always use complex, unique passwords for encryption.
  • Random IV/Nonce: Always enable random IV for encryption operations.
  • Unique Salts: Use a unique random salt for each PBKDF2 operation in production.
  • High Iteration Counts: Use at least 10,000 iterations for PBKDF2 (adjust based on security requirements).
  • AEAD Modes: Prefer authenticated encryption modes (GCM, CFC, OFC, CTC) when possible.
  • Avoid ECB: Never use ECB mode for encrypting multiple blocks of data.
  • Key Management: Implement proper key storage and lifecycle management in production.

Technical Requirements

  • Delphi: RAD Studio 10.3 Rio or later
  • Framework: mORMot V2 (latest version recommended)
  • Platform: Windows 32-bit/64-bit
  • Dependencies: VCL Components (Forms, Controls, etc.)

Contributing

Contributions are welcome! If you have improvements, security enhancements, or bug fixes, please fork the repository and submit a pull request. All cryptographic implementations should follow established security standards and best practices.

License

This project is provided as is without warranty, use at your own risk! Ensure proper security review before using in production environments.

📧 Contact

Discord: BitmasterXor Made with ❤️ by: BitmasterXor using Delphi RAD Studio