Last updated:
0 purchases
lazyxchacha
lazyxchacha #
Lazy XChaCha20-Poly1305 in Flutter base on cryptography
Algorithm details #
Key exchange: X25519
Encryption: XChaCha20
Authentication: Poly1305
Usage #
pubspec.yml
dependencies:
lazyxchacha: ^1.0.0
copied to clipboard
Dart
final lazyxchacha = LazyXChaCha.instance
copied to clipboard
How to use #
Generate KeyPair
final keyPair = await KeyPair.newKeyPair();
copied to clipboard
Key Exchange & Shared Key
final clientKeyPair = await KeyPair.newKeyPair();
final serverKeyPair = await KeyPair.newKeyPair();
final clientSharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
copied to clipboard
Encrypt
final lazyXChaCha = LazyXChaCha.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const plaintext = '{"message": "Hi"}';
final ciphertext = await lazyXChaCha.encrypt(plaintext, sharedKey);
copied to clipboard
Decrypt
final lazyXChaCha = LazyXChaCha.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const ciphertext = '1ec54672d8ef2cca351';
final plaintext = await lazyXChaCha.decrypt(ciphertext, sharedKey);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.