argon2HashPassword method
String
argon2HashPassword(
- String password, {
- Argon2Options options = const Argon2Options(),
- Uint8List? salt,
- Argon2Backend? backend,
Hashes password and encodes the result as a PHC string, the format
$argon2id$v=19$m=65536,t=3,p=1$<salt>$<hash> used by most password
databases.
salt defaults to 16 random bytes taken from OpenSSL's RNG.
Implementation
String argon2HashPassword(
String password, {
Argon2Options options = const Argon2Options(),
Uint8List? salt,
Argon2Backend? backend,
}) {
final effectiveSalt = salt ?? randomBytes(16);
final hash = argon2DeriveFromString(
password,
effectiveSalt,
options: options,
backend: backend,
);
return encodeArgon2Phc(hash, effectiveSalt, options);
}