Crypt class Null safety

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

This class implements SHA-256 and SHA-512 crypt hashes as specified by "Unix crypt using SHA-256 and SHA-512" (version: 0.6 2016-08-31).

Usage

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.

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.

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.
read-only
hashCode int
The hash code for this object.
read-only, override
rounds int?
Number of rounds or null. [...]
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
salt String
The salt value.
read-only
type String
Algorithm used by the crypt. [...]
read-only

Methods

match(String value) bool
Tests if a value hashes to the same hash. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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. [...]
read / write

Constants

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