Crypt class

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

This class implements the SHA-256 crypt hash and SHA-512 crypt hash, cryptographic hash formats that are specified in "Unix crypt using SHA-256 and SHA-512" (version: 0.6 2016-08-31).

Usage

Checking an entered password against a crypt format hash

To test if a value matches a Crypt hash, create a Crypt object from the crypt format string and then invoke the match method with the value being tested.

Creating a crypt format hash

Construct a Crypt object using the Crypt.sha256 or Crypt.sha512 constructors, or by parsing a crypt formatted string with the default Crypt constructor.

The crypt format string value is obtained from a Crypt object by using its toString method.

The value of cryptographicallySecureSalts controls if the use of non-cryptographically secure random number generators are allowed to be used on platforms that do not have a cryptographically secure random number generator. A random number generator is needed if random salts are needed to be generated.

Note: The hashCode method has nothing to do with the crypt hashes. It is a standard method in all Dart objects.

Constructors

Crypt(String cryptFormatStr)
Creates a crypt from a crypt format string.
Crypt.sha256(String key, {int? rounds, String? salt})
Creates a crypt using the SHA-256 algorithm.
Crypt.sha512(String key, {int? rounds, String? salt})
Creates a crypt using the SHA-512 algorithm.

Properties

hash String
The hash value.
no setter
hashCode int
The hash code for this object.
no setteroverride
rounds int?
Number of rounds or null.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
salt String
The salt value.
no setter
type String
Algorithm used by the crypt.
no setter

Methods

match(String value) bool
Tests if a value hashes to the same hash.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Crypt format string.
override

Operators

operator ==(Object that) bool
Equality operator
override

Static Properties

cryptographicallySecureSalts bool
Controls if non-cryptographically secure random salts are allowed.
getter/setter pair

Constants

idSha256 → const String
Crypt ID for the SHA-256 method.
idSha512 → const String