https://github.com/prongbang/lazychacha-flutter
Lazy ChaCha20-Poly1305 in Flutter base on cryptography
https://github.com/prongbang/lazychacha-flutter
chacha20 chacha20-poly1305 lazychacha
Last synced: 6 months ago
JSON representation
Lazy ChaCha20-Poly1305 in Flutter base on cryptography
- Host: GitHub
- URL: https://github.com/prongbang/lazychacha-flutter
- Owner: prongbang
- License: mit
- Created: 2024-04-18T15:17:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-19T08:52:24.000Z (over 1 year ago)
- Last Synced: 2025-03-25T22:52:06.121Z (7 months ago)
- Topics: chacha20, chacha20-poly1305, lazychacha
- Language: Dart
- Homepage: https://pub.dev/packages/lazychacha
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lazychacha
Lazy ChaCha20-Poly1305 in Flutter base on [cryptography](https://pub.dev/packages/cryptography)
[](https://www.buymeacoffee.com/prongbang)
### Algorithm details
- Key exchange: X25519
- Encryption: ChaCha20
- Authentication: Poly1305## Usage
- pubspec.yml
```yaml
dependencies:
lazychacha: ^1.0.0
```- Dart
```dart
final lazychacha = LazyChaCha.instance;
```## How to use
- Generate KeyPair
```dart
final keyPair = await KeyPair.newKeyPair();
```- Key Exchange & Shared Key
```dart
final clientKeyPair = await KeyPair.newKeyPair();
final serverKeyPair = await KeyPair.newKeyPair();final clientSharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
```- Encrypt
```dart
final lazyChaCha = LazyChaCha.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const plaintext = '{"message": "Hi"}';final ciphertext = await lazyChaCha.encrypt(plaintext, sharedKey);
```- Decrypt
```dart
final lazyChaCha = LazyChaCha.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const ciphertext = '1ec54672d8ef2cca351';final plaintext = await lazyChaCha.decrypt(ciphertext, sharedKey);
```