flutter_sodium 0.0.5

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 84

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

Dart APIs

The plugin includes a core API that maps native libsodium functions 1:1 to Dart equivalents. The core API is available in the class Sodium. Dart naming conventions are used for core API function names. A native libsodium function such as crypto_pwhash_str, is available in flutter as Sodium.cryptoPwhashStr.

Also included in flutter_sodium is a high-level, opinionated API providing access to libsodium in a Dart friendly manner. The various functions are available in separate Dart classes. Password hashing for example is available in the PasswordHash class.

The high-level API depends on the core API to get things done.

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);

Example app

This project includes an extensive example app with runnable code samples. Be sure to check it out!

Current issues

  • Some APIs are not available in Android (this needs to be documented).
  • 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.

0.0.5 - August 5, 2018

  • breaking high-level API changes
    • String operations now default
    • Randombytes renamed to RandomBytes
  • adds CryptoBox, KeyDerivation, KeyExchange and ScalarMult highlevel APIs

0.0.4 - July 31, 2018

  • No functional changes
  • Fixes SDK constraint and source file formatting

0.0.3 - July 30, 2018

  • Adds Dart-friendly APIs
  • Introduces example app with runnable code samples
  • Replaces deprecated code constructs

0.0.2 - April 12, 2018

  • Adds support for Flutter Beta 2 and Dart 2

0.0.1 - March 20, 2018

  • Initial release with core libsodium API support.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_sodium: ^0.0.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_sodium/flutter_sodium.dart';
  
Version Uploaded Documentation Archive
0.0.5 Aug 5, 2018 Go to the documentation of flutter_sodium 0.0.5 Download flutter_sodium 0.0.5 archive
0.0.4 Jul 31, 2018 Go to the documentation of flutter_sodium 0.0.4 Download flutter_sodium 0.0.4 archive
0.0.3 Jul 30, 2018 Go to the documentation of flutter_sodium 0.0.3 Download flutter_sodium 0.0.3 archive
0.0.2 Apr 12, 2018 Go to the documentation of flutter_sodium 0.0.2 Download flutter_sodium 0.0.2 archive
0.0.1 Mar 20, 2018 Go to the documentation of flutter_sodium 0.0.1 Download flutter_sodium 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
69
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8
  • Flutter: 0.5.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Maintain an example.

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use flutter_sodium.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.11
meta 1.1.5 1.1.6
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.8