crypt 1.0.7 copy "crypt: ^1.0.7" to clipboard
crypt: ^1.0.7 copied to clipboard

outdated

One-way string hashing for salted passwords using the Unix crypt format

example/crypt.dart

// Copyright (c) 2015, 2016, 2017, Hoylen Sue. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library crypt.example;

import 'package:crypt/crypt.dart';

void main() {
  final c1 = new Crypt.sha256("p@ssw0rd"); // default rounds, random salt
  final c2 = new Crypt.sha256("p@ssw0rd", rounds: 10000); // random salt
  final c3 =
      new Crypt.sha256("p@ssw0rd", salt: "abcdefghijklmnop"); // default rounds
  final c4 =
      new Crypt.sha256("p@ssw0rd", rounds: 10000, salt: "abcdefghijklmnop");

  print(c1.toString());
  print(c2.toString());
  print(c3.toString());
  print(c4.toString());

  var suppliedValue = "p@ssw0rd";
  if (c1.match(suppliedValue)) {
    print("Correct value match");
  } else {
    print("Error: unexpected non-match: $suppliedValue");
  }

  suppliedValue = "123456";
  if (c1.match(suppliedValue)) {
    print("Error: unexpected match: $suppliedValue");
  } else {
    print("Incorrect value does not match");
  }
}
34
likes
35
pub points
94%
popularity

Publisher

verified publisherhoylen.com

One-way string hashing for salted passwords using the Unix crypt format

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

crypto

More

Packages that depend on crypt