tweetnacl 0.3.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

A library for Dart developers.

Usage #

A simple usage example:

import 'package:tweetnacl/tweetnacl.dart';
import "dart:convert";
import 'dart:typed_data';

void main(){
  KeyPair kp = Signature.keyPair();
  print("secretKey: \"${TweetNaclFast.hexEncodeToString(kp.secretKey)}\"");
  print("publicKey: \"${TweetNaclFast.hexEncodeToString(kp.publicKey)}\"");

  Uint8List bytes = utf8.encode("test string");
  Signature s1 = Signature(null, kp.secretKey);
  Uint8List signature = s1.detached(bytes);
  print("signature: \"${TweetNaclFast.hexEncodeToString(signature)}\"");

  Signature s2 = Signature(kp.publicKey, null);
  bool result = s2.detached_verify(bytes,  signature);
  print("verify: \"${result}\"");

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.3.1 #

  • Initial version, created by Jeff Lee

0.3.2 #

  • Replace large integer constants with Int64


import 'package:tweetnacl/tweetnacl.dart';
import "dart:convert";
import 'dart:typed_data';

void testSignDetached(String seedStr) {

  List<int> seed = TweetNaclFast.hexDecode(seedStr);
  KeyPair kp = Signature.keyPair_fromSeed(seed);

  String testString = "test string";
  Uint8List bytes = utf8.encode(testString);

  Signature s1 = Signature(null, kp.secretKey);
  Uint8List signature = s1.detached(bytes);

  Signature s2 = Signature(kp.publicKey, null);
  bool result = s2.detached_verify(bytes,  signature);

  assert(result == true);

void main() {

Use this package as a library

1. Depend on it

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

  tweetnacl: ^0.3.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:tweetnacl/tweetnacl.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 Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Document public APIs. (-0.33 points)

128 out of 131 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/tweetnacl_base.dart. (-25 points)

Analysis of lib/src/tweetnacl_base.dart reported 72 hints, including:

line 187 col 7: DO use curly braces for all flow control structures.

line 255 col 36: DO use curly braces for all flow control structures.

line 258 col 7: DO use curly braces for all flow control structures.

line 264 col 42: DO use curly braces for all flow control structures.

line 291 col 7: DO use curly braces for all flow control structures.

Maintenance suggestions

The package description is too short. (-12 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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
convert ^2.0.2 2.1.1
fixnum ^0.10.9 0.10.11
Transitive dependencies
charcode 1.1.3
typed_data 1.1.6
Dev dependencies
test ^1.0.0