dbcrypt 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

DBCrypt #

Port of jBCrypt to Dart.

This system hashes passwords using a version of Bruce Schneier's Blowfish block cipher with modifications designed to raise the cost of off-line password cracking. The computation cost of the algorithm is parameterised, so it can be increased as computers and Dart VM get faster.

Build Status

Installation #

Add to your pubspec.yaml the following:

  dbcrypt: ^1.0.0

Usage #

Hashing a password is easy:

import 'package:dbcrypt/dbcrypt.dart'

main() {
  var plainPassword = "P@55w0rd";
  var hashedPassword = new DBCrypt().hashpw(plainPassword, new DBCrypt().gensalt());

Comparing a plain and a hashed password is even easier:

var isCorrect = new DBCrypt().checkpw(plain, hashed);

Running Tests #

Dependencies are installed using the Pub Package Manager.

# For running the tests it needs the 'dart' executable on your path. 
# Execute the next command if it isn't already on your path:
export DART_SDK=path/to/dart/sdk

pub install


1.0.0 #

  • Upgrade to Dart 2
  • Add support for $2y$ and $2b$ versions of BCrypt
  • Password are now generated with $2b$ since this lib doesn't have the OpenBSD $2a$ version bug

0.2.0 #

  • Upgrade to Dart 1


import 'package:dbcrypt/dbcrypt.dart';

void main() {
  DBCrypt dBCrypt = DBCrypt();
  const plainPwd = "mySuperSecretP@ssw0rd";
  // Hash password with default values
  String hashedPwd = dBCrypt.hashpw(plainPwd, dBCrypt.gensalt());

  // Check the plain password against the hashed password
  assert(dBCrypt.checkpw(plainPwd, hashedPwd), true);

  // Generate a salt with a cost of 12 and hash the password with it
  String salt = dBCrypt.gensaltWithRounds(12);
  hashedPwd = dBCrypt.hashpw(plainPwd, salt);

  // Check the plain password against the 12-cost hashed password
  assert(dBCrypt.checkpw(plainPwd, hashedPwd), true);

Use this package as a library

1. Depend on it

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

  dbcrypt: ^1.0.0

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:dbcrypt/dbcrypt.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 27, 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

Fix lib/dbcrypt.dart. (-13.09 points)

Analysis of lib/dbcrypt.dart reported 28 hints, including:

line 67 col 29: Unnecessary new keyword.

line 69 col 29: Unnecessary new keyword.

line 72 col 42: Unnecessary new keyword.

line 143 col 30: Unnecessary new keyword.

line 146 col 18: Unnecessary new keyword.

Maintenance suggestions

Package is getting outdated. (-48.77 points)

The package was last published 77 weeks ago.

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <3.0.0
Dev dependencies
benchmark_harness >=1.0.2 <2.0.0
test ^1.3.0