blake2 0.1.1

  • Readme
  • Changelog
  • Installing
  • 65

blake2 #

Pure Dart implementations of the BLAKE2b and BLAKE2s cryptographic hashing functions.

Usage #

import 'package:blake2/blake2.dart';

The blake2 library contains 3 classes: [Blake2b], [blake2s], and their parent class: [blake2].

Both [Blake2b] and [Blake2s] can be instanced directly, accepting [Uint8List]s for the [key], [salt] and [personalization] parameters.

An [iv] can also be specified as a [Uint64List] or [Uint32List], for [Blake2b] and [Blake2s] respectively.

All of the parameters are optional and can be left null.

The hash can be returned as a [Uint8List] with the digest() method, or as a [String] with the digestToString() method.

const String key = '7a546d0acf4f30d371c505f32548c867';
const String salt = '39b69017';
const String personalization = '4d97847f';

final Blake2b blake2b = Blake2b(
  key: Uint8List.fromList(key.codeUnits),
  salt: Uint8List.fromList(salt.codeUnits),
  personalization: Uint8List.fromList(personalization.codeUnits),


// Prints: [179, 80, 231, 226, 92, 124, 89, 99, 133, 217, 254, 167, 78, 189, 21, 254, 209, 126, 124, 142, 180, 193, 37, 196, 83, 167, 106, 44, 107, 178, 135, 23]


// Prints: “Ó˜‹Zêœ]ג8ƒ£ÛU]ÚÙ¬DÛ!;s¶„Ø

blake2b.update(Uint8List.fromList([110, 101, 119, 32, 100, 97, 116, 97]));


// Prints: {é2¾ë];²à&Õ½BXNŒ¼ý(³ö(î&?½ND_

Each class also has a static method fromStrings(), that accepts the [key], [salt], and [personalization] parameters as [String]s, and a method updateWithString() to add additional data as a [String].

final Blake2s blake2s = Blake2s.fromStrings(
  key: '2805f1ad825b3489dae4c5526014c1ed',
  salt: '8d6efe2c',
  personalization: 'e9f6def7',


// Prints: Ãɚ؍NP™nû·Ì‡÷Eæüç™-SºØ·Ò=ëˆik

blake2s.updateWithString('new data');


// Prints: ßlF‚©óþ;•+®Ð¸BaðŪ_#‘Y¥\Ž–²p

[0.1.1] - January 15, 2020

  • Formatting changes

[0.1.0] - July 27, 2019

  • Initial release

Use this package as a library

1. Depend on it

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

  blake2: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:blake2/blake2.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Format lib/src/blake2b.dart.

Run dartfmt to format lib/src/blake2b.dart.

Format lib/src/blake2s.dart.

Run dartfmt to format lib/src/blake2s.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and blake2.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
effective_dart ^1.0.0
test ^1.6.5