Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prongbang/lazyxchacha-flutter
Lazy XChaCha20-Poly1305 in Flutter base on cryptography
https://github.com/prongbang/lazyxchacha-flutter
lazyxchacha xchacha20 xchacha20-poly1305
Last synced: 11 days ago
JSON representation
Lazy XChaCha20-Poly1305 in Flutter base on cryptography
- Host: GitHub
- URL: https://github.com/prongbang/lazyxchacha-flutter
- Owner: prongbang
- License: apache-2.0
- Created: 2024-04-13T13:17:44.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-04-13T16:03:33.000Z (8 months ago)
- Last Synced: 2024-04-14T05:30:39.296Z (8 months ago)
- Topics: lazyxchacha, xchacha20, xchacha20-poly1305
- Language: Dart
- Homepage: https://pub.dev/packages/lazyxchacha
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lazyxchacha
Lazy XChaCha20-Poly1305 in Flutter base on [cryptography](https://pub.dev/packages/cryptography)
[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/prongbang)
### Algorithm details
- Key exchange: X25519
- Encryption: XChaCha20
- Authentication: Poly1305## Usage
- pubspec.yml
```yaml
dependencies:
lazyxchacha: ^1.0.0
```- Dart
```dart
final lazyxchacha = LazyXChaCha.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 lazyXChaCha = LazyXChaCha.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const plaintext = '{"message": "Hi"}';final ciphertext = await lazyXChaCha.encrypt(plaintext, sharedKey);
```- Decrypt
```dart
final lazyXChaCha = LazyXChaCha.instance;
final sharedKey = await clientKeyPair.sharedKey(serverKeyPair.pk);
const ciphertext = '1ec54672d8ef2cca351';final plaintext = await lazyXChaCha.decrypt(ciphertext, sharedKey);
```