encryptions 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

encryptions #

A plugin for using native AES /Argon2 algorithms in Android/IOS.

Test report

Getting Started #

Supported algorithms:

  • AES(128bit or 256bit) in ECB or CBC mode, with NoPadding or PKCS5Padding
  • argon2i, argon2d, argon2id

AES example usage #

Uint8List key256 = hex
    .decode("163928fb9615edf6005afc98d9fdbb3d830b3a286ebef64dd70be848f17bf9cc");
Uint8List iv = hex.decode("c1f6fd873e14050697c168b3e9da5db2");
Uint8List plain = hex.decode("01040000000300000002400000008b2e");

AES aes = AES.ofCBC(key256, iv, PaddingScheme.PKCS5Padding);
    Uint8List encrypted = await aes.encrypt(plain);
    Uint8List decrypted = await aes.decrypt(encrypted);

Argon2 example usage #

Uint8List password = utf8.encode("password");
Uint8List salt = utf8.encode("helloworld");

Argon2 argon2 = Argon2(iterations: 16, hashLength: 64, memory: 256, parallelism: 2);
    Uint8List hash = await argon2.argon2i(password, salt);

for more details, try to have a look at example/lib/platform_test.dart

0.0.1 #

Notice: version 0.0.1 is deprecated, consider using the latest version.

  • Support for AES/CBC/NoPadding
  • Support for argon2i, argon2d with pre-configured arguments

0.0.2 (Latest) #

  • Full support for AES(128bit, 256bit) in CBC/ECB mode, also support NoPadding or PKCS5Padding
  • Full support for argon2i, argon2d, argon2id
  • Now it's able to configure custom argon2 parameters
  • Added a test report UI in example, for which you can validate the result in real devices

0.0.3 (Testing) #

  • Implicitly declare api return value type
  • Using separate thread to run android native code, thus it might help to un-block the ui thread

example/lib/main.dart

import 'package:encryptions_example/platform_test.dart';
import 'package:flutter/material.dart';
import 'dart:async';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Future<List<Report>> reports;

  @override
  void initState() {
    super.initState();
    reports = test();
  }

  static const headerStyle =
      TextStyle(fontSize: 16, fontWeight: FontWeight.bold);
  static const successStyle = TextStyle(fontSize: 16, color: Colors.green);
  static const errorStyle = TextStyle(fontSize: 16, color: Colors.red);
  static const padding = EdgeInsets.all(5.0);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Padding(
          padding: const EdgeInsets.only(top: 20.0, left: 5, right: 5),
          child: _renderReport(),
        ),
      ),
    );
  }

  Widget _renderTable(List<TableRow> rows) {
    return SingleChildScrollView(
      child: Table(
        border: new TableBorder.all(width: 1.0, color: Colors.grey),
        children: <TableRow>[
          TableRow(children: <Widget>[
            TableCell(
              child: Padding(
                padding: padding,
                child: Text('Test', style: headerStyle),
              ),
            ),
            TableCell(
              child: Padding(
                padding: padding,
                child: Text('Result', style: headerStyle),
              ),
            ),
          ]),
          ...rows
        ],
      ),
    );
  }

  TableRow _createRow(Report report) {
    return TableRow(key: ObjectKey(report.name), children: <Widget>[
      TableCell(
        child: Padding(
          padding: padding,
          child: Text(report.name),
        ),
      ),
      TableCell(
        child: Padding(
          padding: padding,
          child: Text(
            "${report.success}",
            style: report.success ? successStyle : errorStyle,
          ),
        ),
      ),
    ]);
  }

  Widget _renderReport() {
    return FutureBuilder<List<Report>>(
      future: reports,
      builder: (_, snapshot) {
        switch (snapshot.connectionState) {
          case ConnectionState.done:
            if (snapshot.hasError) {
              print('got error! ${snapshot.error}');
              return Text("Error:${snapshot.error}");
            }
            print("Done! ${snapshot.data}");
            return _renderTable(
                snapshot.data.map((report) => _createRow(report)).toList());
          default:
            return Center(
              child: Text("Testing..."),
            );
        }
      },
    );
  }

  Future<List<Report>> test() async {
    List<Report> reports = [];
    for (int i = 0; i < tests.length; i++) {
      PlatformTest t = tests[i];
      bool success;
      try {
        success = await t.executor();
      } catch (err, stack) {
        print(err);
        print(stack);
        success = false;
      }
      reports.add(Report(t.name, success));
    }
    return reports;
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  encryptions: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:encryptions/encryptions.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
68
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:encryptions/encryptions.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:encryptions/encryptions.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:encryptions/encryptions.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:encryptions/encryptions.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [encryptions] that is in a package requiring null.

Health suggestions

Format lib/src/argon2.dart.

Run flutter format to format lib/src/argon2.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The package description is too short. (-5 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
convert ^2.1.1 2.1.1
flutter 0.0.0
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test