sha3 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

SHA3 for Dart #

A SHA3 library which contains SHA3 keccak SHAKE CSHAKE KMAC for Dart developers.

SHA3 is translated from https://github.com/emn178/js-sha3

Example #

Read sha3_example.dart or pub.dev doc and get datailed doc & examples

0.1.0 #

  • enhance doc and code
  • add and pass the shake test

0.1.0 #

  • Initial version, created by Stagehand and pass the simple test

example/sha3_example.dart

import 'dart:convert';

import 'package:hex/hex.dart';
import 'package:sha3/sha3.dart';

void main() {
  /* SHA3(int bits, List<int> padding, int outputBits)
    Avaliable `bits`: 
      - for keccak and sha3: use number in `NORMAL_BITS`: [224, 256, 384, 512];
      - for shake cshake: use number in `SHAKE_BITS`: [128, 256];

    Avaliable `padding`:
      - SHA3_PADDING: for sha3;
      - KECCAK_PADDING: for keccak;
      - SHAKE_PADDING: for shake;
      - CSHAKE_PADDING: for cshake;

    Avaliable `outputBits`:
      same to `bits`;
   */
  var k = SHA3(256, KECCAK_PADDING, 256);
  k.update(utf8.encode('Hello'));
  var hash = k.digest();
  print(HEX.encode(
      hash)); // 06b3dfaec148fb1bb2b066f10ec285e7c9bf402ab32aa78a5d38e34566810cd2

  /* KMAC(dynamic bits, dynamic padding, dynamic outputBits)
    Avaliable `bits`: use number in `SHAKE_BITS`: [128, 256];
    Avaliable `padding`: CSHAKE_PADDING;
    Avaliable `outputBits`: same to `bits`;
   */
  var kmac = KMAC(256, CSHAKE_PADDING, 256);
  kmac.update(utf8.encode('Hello'));
  var kmac_hash = kmac.digest();
  print(HEX.encode(kmac_hash));
}

Use this package as a library

1. Depend on it

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


dependencies:
  sha3: ^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:sha3/sha3.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
56
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]
78
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.8.1 <3.0.0
Dev dependencies
hex ^0.1.2
pedantic ^1.9.0
test ^1.14.4