Argon2 class
Creates a context for Argon2 password hashing.
Argon2 is a key derivation algorithm that was selected as the winner of the 2015 Password Hashing Contest, and the best password hashing / key derivation algorithm known to date.
Example of password hashing using Argon2:
final salt = utf.encode("some salt")
final password = utf8.encode('password');
final argon2 = Argon2(
version: Argon2Version.v13,
type: Argon2Type.argon2id,
hashLength: 32,
iterations: 2,
parallelism: 8,
memorySizeKB: 1 << 18,
salt: salt,
);
final digest = argon2.encode(password);
- Inheritance
-
- Object
- KeyDerivatorBase
- Argon2
Constructors
-
Argon2.new({Argon2Type type = Argon2Type.argon2id, Argon2Version version = Argon2Version.v13, required int parallelism, required int memorySizeKB, required int iterations, int? hashLength, List<
int> ? salt, List<int> ? key, List<int> ? personalization}) -
factory
-
Argon2.fromEncoded(CryptData data, {List<
int> ? key, List<int> ? personalization}) -
Creates an Argon2 instance from an encoded PHC-compliant string.
factory
-
Argon2.fromSecurity(Argon2Security security, {List<
int> ? salt, List<int> ? key, int? hashLength, List<int> ? personalization}) -
Creates an Argon2 instance from Argon2Security parameter.
factory
Properties
- derivedKeyLength → int
-
The length of derived key in bytes
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- hashLength → int
-
Desired number of returned bytes
no setter
- iterations → int
-
Number of iterations to perform
no setter
-
key
→ List<
int> ? -
Optional key
no setter
- memorySizeKB → int
-
Amount of memory (in kibibytes) to use
no setter
- name → String
-
The name of this algorithm
no setteroverride
- parallelism → int
-
Degree of parallelism (i.e. number of threads)
no setter
-
personalization
→ List<
int> ? -
Optional arbitrary additional data
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
salt
→ List<
int> -
Salt (16 bytes recommended for password hashing)
no setter
- type → Argon2Type
-
Argon2 Hash Type
no setter
- version → Argon2Version
-
The current version is 0x13 (decimal: 19)
no setter
Methods
-
convert(
List< int> password) → Argon2HashDigest -
Generate a derived key from a
password
using Argon2 algorithmoverride -
encode(
List< int> password) → String -
Generate an Argon2 encoded string from a
password
-
hex(
List< int> password) → String -
Returns the derived key in hexadecimal.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
string(
String password, [Encoding? encoding]) → HashDigest -
Process the
password
string and returns derived key as HashDigest.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
verify(
List< int> derivedKey, List<int> password) → bool -
Verify if the
derivedKey
was derived from the originalpassword
using the current parameters.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited