flutter_sodium 0.0.4 flutter_sodium: ^0.0.4 copied to clipboard
Flutter bindings for libsodium, a modern, easy-to-use crypto library.
flutter_sodium #
With flutter_sodium you get access to the modern, easy-to-use libsodium crypto library in your Flutter apps. One set of crypto APIs supporting both Android and iOS.
API coverage #
At this point in time flutter_sodium implements the following high-level libsodium APIs:
- crypto_auth
- crypto_box
- crypto_generichash
- crypto_kdf
- crypto_kx
- crypto_onetimeauth
- crypto_pwhash
- crypto_scalarmult
- crypto_secretbox
- crypto_shorthash
- crypto_sign
- randombytes
- sodium_version
Example app #
This project includes an extensive example app with runnable code samples. Be sure to check it out!
Roadmap #
- A core API that maps 1:1 to libsodium functions. Should cover the entire high-level API.
- Proper argument checks
- Fix missing API functions (such as crypto_pwhash_str_needs_rehash)
- A Dart-friendly, opinionated API wrapping the core API. Should work with types other than Uint8List such as strings, streams, etc.
Getting Started #
In your flutter project add the dependency:
dependencies:
...
flutter_sodium: any
Important: For iOS you'll need to manually update the Podfile in your ios project.
Usage example #
import 'package:flutter_sodium/flutter_sodium.dart';
// Password hashing (using Argon)
final password = 'my password';
final str = await PasswordHash.hashStorage(password);
print(str);
// verify hash str
final valid = await PasswordHash.verifyStorage(str, password);
assert(valid);
Current issues #
- Some APIs are not available yet in Android
- Using flutter_sodium in iOS doesn't work right out of the box. Manual installation steps are required.
- Since Flutter does not support native binaries, a platform channel is established to enable native function invocation. One side effect of this approach is that the entire flutter_sodium API is asynchronous. This is great for potential long-running operations such as Argon password hashing, but does not make much sense for other short-running functions.