cryptum_dart 0.0.4 copy "cryptum_dart: ^0.0.4" to clipboard
cryptum_dart: ^0.0.4 copied to clipboard

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

example/README.md

Cryptum Example #

This example demonstrates the core functionality of the Cryptum package for secure message encryption and decryption.

Features Demonstrated #

  • Key pair generation
  • Message encryption and decryption
  • Message format handling
  • Error handling for format mismatches
  • Tamper detection

Code Walkthrough #

The example simulates a secure message exchange between two parties (Alice and Bob):

  1. Initialize Cryptum Instances
final alice = Cryptum();
final bob = Cryptum();
  1. Generate Key Pairs
final aliceKeys = await alice.generateKey();
final bobKeys = await bob.generateKey();
  1. Create and Format Message
final message = 'Hello, this is a secret message!';
final messageBytes = Uint8List.fromList(utf8.encode(message));
  1. Generate Message Formats
final aliceFormat = MessageFormat.generateRandom();
final bobFormat = MessageFormat.generateRandom();
  1. Encrypt Message
final encrypted = await alice.encryptBlob(
  messageBytes,
  bobKeys['public']!,
  format: aliceFormat,
);
  1. Decrypt Message
final decrypted = await bob.decryptBlob(
  encrypted,
  bobKeys['private']!,
  format: aliceFormat,
);

The example also includes error handling demonstrations for:

  • Using mismatched message formats
  • Attempting to decrypt messages with incorrect keys

Running the Example #

To run this example:

  1. Ensure you have the Cryptum package added to your pubspec.yaml:
dependencies:
  cryptum_dart: ^1.0.0
  1. Run the example:
dart run example/cryptum_example.dart
1
likes
150
points
28
downloads

Publisher

verified publisherthreatflux.ai

Weekly Downloads

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

Repository (GitHub)
View/report issues

Topics

#cryptography #security #encryption #rsa #aes

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

asn1lib, collection, pointycastle

More

Packages that depend on cryptum_dart