rusty_chacha 0.1.1-dev.2 rusty_chacha: ^0.1.1-dev.2 copied to clipboard
A Flutter library for fast ChaCha20-Poly1305 encryption, powered by Rust
Rusty ChaCha 💃🦀 #
A Flutter library for fast ChaCha20-Poly1305 encryption, leveraging the capabilities of the Rust chacha20poly1305 crate.
🚧 Under Development: Not recommended for production use. 🚧
Features #
- Encrypt and decrypt data with ChaCha20-Poly1305 (authenticated)
- Additional authenticated data (AAD)
- Optional compression using zstd
Blazingly fast 🔥 #
Thanks to Rust encryption and decryption with ChaCha20-Poly1305 run with at 500-1000 MiB/s. This is up to 50x faster than packages like cryptography_flutter or pointycastle.
Getting Started #
- With Flutter, run
flutter pub add rusty_chacha
Usage #
import 'package:rusty_chacha/rusty_chacha.dart';
main() async {
await RustyChaCha.init();
final key = await generateChaCha20Key(); // generate a random key
final myData = Uint8List.fromList([1, 2, 3, 4, 5]);
// basic example:
final myEncryptedData = await encrypt(key: key, cleartext: myData);
final myDataAgain1 = await decrypt(key: key, ciphertext: myEncryptedData);
// compression example:
final myCompressedAndEncryptedData = await encrypt(
key: key,
cleartext: myData,
zstdCompressionLevel: 3, // moderate compression
);
final myDataAgain2 = await decrypt(key: key, ciphertext: myCompressedAndEncryptedData);
// AAD example:
final additionalData = Uint8List.fromList([1, 2, 3]); // some additional (non-secret) data
final myEncryptedDataWithAad = await encrypt(
key: key,
cleartext: myData,
aad: additionalData, // pass it in when encrypting
);
final myDataAgain3 = await decrypt(
key: key,
ciphertext: myEncryptedDataWithAad,
aad: additionalData, // pass it in to decrypt (decrypt will fail if additionalData is not the same)
);
}
Supported platforms (for now) #
- iOS
- MacOS
- Windows