Cryptum-Dart
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