blake2 0.1.0+2

blake2 #

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

This library's implementations are based on: https://github.com/thesimj/js-blake2s, with reference to the official BLAKE2 C implementations: https://github.com/BLAKE2/libb2

Usage #

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

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

All of the arguments 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),
);

print(blake2b.digest());

// 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]

print(blake2b.digestToString());

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

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

print(blake2b.digestToString());

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

Each class also has a static method fromStrings(), that accepts the [key], [salt], and [personalization] arguments 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',
);

print(blake2s.digestToString());

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

blake2s.updateWithString('new data');

print(blake2s.digestToString());

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

Warning #

This package has not been evaluated by security experts and may not be ready for production use in applications where security depends on it.

[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:


dependencies:
  blake2: ^0.1.0+2

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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:blake2/blake2.dart.

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/README.md.

For more information see the pub package layout conventions.

Dependencies

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