Argon2HashUtil.forRandomSecrets constructor

Argon2HashUtil.forRandomSecrets({
  1. required String hashPepper,
  2. List<String> fallbackHashPeppers = const [],
  3. required int hashSaltLength,
})

Creates an Argon2HashUtil for secrets that are long and randomly generated, such as tokens. Never use it for passwords or short codes.

Nobody can guess such a secret, so the slowness of Argon2 protects nothing. This hashes at the lowest cost Argon2 allows. The stored format is unchanged, so servers on an earlier version still validate these hashes. Hashes stored at a higher cost validate here too.

Implementation

Argon2HashUtil.forRandomSecrets({
  required final String hashPepper,
  final List<String> fallbackHashPeppers = const [],
  required final int hashSaltLength,
}) : this._(
       hashPepper: hashPepper,
       fallbackHashPeppers: fallbackHashPeppers,
       hashSaltLength: hashSaltLength,
       parameters: Argon2HashParameters(memory: 8, iterations: 1, lanes: 1),
       minSecretLength: minRandomSecretLength,
     );