Skip to content

prongbang/lazyaesgcm-flutter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lazyaesgcm

Lazy AES-GCM in Flutter base on cryptography

"Buy Me A Coffee"

Algorithm details

  • Key exchange: X25519
  • Encryption: AES
  • Authentication: GCM

Usage

  • pubspec.yml
dependencies:
  lazyaesgcm: ^1.0.0
  • Dart
final lazyaesgcm = LazyAesGcm.instance;

How to use

  • Generate KeyPair
final keyPair = await KeyPair.newKeyPair();
  • Key Exchange & Shared Key
final clientKeyPair = await KeyPair.newKeyPair();
final serverKeyPair = await KeyPair.newKeyPair();

final clientSharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
  • Encrypt
final lazyaesgcm = LazyAesGcm.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const plaintext = '{"message": "Hi"}';

final ciphertext = await lazyaesgcm.encrypt(plaintext, sharedKey);
  • Decrypt
final lazyaesgcm = LazyAesGcm.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const ciphertext = '1ec54672d8ef2cca351';

final plaintext = await lazyaesgcm.decrypt(ciphertext, sharedKey);