lazyxchacha 1.0.1 copy "lazyxchacha: ^1.0.1" to clipboard
lazyxchacha: ^1.0.1 copied to clipboard

Lazy XChaCha20-Poly1305 in Flutter base on cryptography

example/main.dart

import 'package:flutter/foundation.dart';
import 'package:lazyxchacha/keypair.dart';
import 'package:lazyxchacha/lazyxchacha.dart';

void main() async {
  final lazyxchacha = LazyXChaCha.instance;

  // Generate KeyPair
  final clientKeyPair = await KeyPair.newKeyPair();
  final serverKeyPair = await KeyPair.newKeyPair();

  // Key Exchange
  final clientSharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
  final serverSharedKey = await serverKeyPair.sharedKey(clientKeyPair.pk);

  // Payload
  const message = 'Hello lazyxchacha';

  // Encrypt with client
  final ciphertext = await lazyxchacha.encrypt(message, clientSharedKey);

  // Decrypt with server
  final plaintext = await lazyxchacha.decrypt(ciphertext, serverSharedKey);

  // Output
  debugPrint('Output: $plaintext');
}
2
likes
140
pub points
0%
popularity

Publisher

verified publisherwachasit.com

Lazy XChaCha20-Poly1305 in Flutter base on cryptography

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

convert, cryptography, flutter

More

Packages that depend on lazyxchacha