Cryptum-Dart

Dart CI/CD codecov pub package License: MIT Dart 2.19+ Code style: lint Codacy Badge

A Dart port of the Cryptum encryption library providing hybrid RSA/AES-GCM encryption with secure session key handling and dynamic format negotiation.

Features

  • πŸ” 4096-bit RSA key generation
  • πŸ”„ Hybrid encryption (RSA + AES-GCM)
  • πŸ”‘ Secure session key handling
  • βœ… Message authentication (GCM)
  • πŸ“œ PKCS8/X509 key encoding
  • 🎲 Secure random number generation
  • πŸ”€ Dynamic message format negotiation

Prerequisites

  • Dart SDK 2.19 or higher

Installation

Add this to your pubspec.yaml:

dependencies:
  cryptum_dart: ^0.0.1

Then run:

dart pub get

Basic Usage

import 'package:cryptum_dart/cryptum_dart.dart';

void main() async {
  final cryptum = Cryptum();
  
  // Generate key pair
  final keys = await cryptum.generateKey();
  
  // Encrypt data
  final message = Uint8List.fromList(utf8.encode('Secret message'));
  final encrypted = await cryptum.encryptBlob(message, keys['public']!);
  
  // Decrypt data
  final decrypted = await cryptum.decryptBlob(encrypted, keys['private']!);
  print(utf8.decode(decrypted)); // 'Secret message'
}

Advanced Usage

Format Negotiation

Cryptum supports dynamic message format negotiation for enhanced security:

final format = MessageFormat.generateRandom();

// Encrypt with format
final encrypted = await cryptum.encryptBlob(
  message, 
  publicKey,
  format: format
);

// Decrypt with same format
final decrypted = await cryptum.decryptBlob(
  encrypted, 
  privateKey,
  format: format
);

Security Features

  • πŸ”’ AES-256 for symmetric encryption
  • πŸ›‘οΈ RSA-4096 for key encryption
  • βœ”οΈ GCM authentication
  • πŸ” Secure session key generation
  • πŸ›‘ Tamper detection
  • ⚑ Constant-time MAC comparison
  • πŸ”€ Dynamic message formatting

Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/ThreatFlux/Cryptum-Dart.git
cd Cryptum-Dart

# Get dependencies
dart pub get

# Run tests
dart test

Running Tests

# Run all tests
dart test

# Run with coverage
dart test --coverage=coverage

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

CI/CD

This project uses GitHub Actions for continuous integration and deployment:

  • Automated testing on each push and pull request
  • Code coverage reporting via Codecov
  • Automatic publishing to pub.flutter-io.cn when tests pass
  • Code formatting and analysis checks

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

  • Wyatt Roersma - Project Lead - GitHub
  • Claude 3.5 Sonnet 20241022 - Dart Port Development Support

Version History

See CHANGELOG.md for all changes.


Made with ❀️ by the ThreatFlux team

Libraries

cryptum_dart