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

Lazy ChaCha20-Poly1305 in Flutter base on cryptography

example/main.dart

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

void main() async {
  final lazychacha = LazyChaCha.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 lazychacha';

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

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

  // Output
  if (kDebugMode) {
    print('Output: $plaintext');
  } // Output: Hello lazychacha
}
2
likes
140
points
22
downloads

Publisher

verified publisherwachasit.com

Weekly Downloads

Lazy ChaCha20-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 lazychacha