dbcrypt 1.0.0 copy "dbcrypt: ^1.0.0" to clipboard
dbcrypt: ^1.0.0 copied to clipboard

outdated

A port of jBCrypt to Dart. It allows to encrypt passwords using BCrypt with a configurable work factor to make it more expensive to create (and secure) as machines get faster. It also allows to check [...]

example/example.dart

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);
}
46
likes
20
points
20.9k
downloads

Publisher

verified publishererlantz.net

Weekly Downloads

A port of jBCrypt to Dart. It allows to encrypt passwords using BCrypt with a configurable work factor to make it more expensive to create (and secure) as machines get faster. It also allows to check passwords that have been encrypted using the original BCrypt algorithm and it's a, y and b revisions.

Repository (GitHub)

License

unknown (license)

More

Packages that depend on dbcrypt