createHashFromBytes method

Future<String> createHashFromBytes({
  1. required Uint8List secret,
  2. @protected Uint8List? salt,
})

Create the hash for the given secret (Uint8List).

Applies a random salt, which must be stored with the hash to validate it later. If salt is provided, it will be used instead of generating a random one.

Returns a PHC-formatted string: $argon2id$v=19$m={memory},t={iterations},p={lanes}${base64Salt}${base64Hash}

Implementation

Future<String> createHashFromBytes({
  required final Uint8List secret,
  @protected Uint8List? salt,
}) async {
  salt ??= generateRandomBytes(_hashSaltLength);
  final pepper = _hashPeppers.first;

  final result = await _createHash(
    secret: secret,
    salt: salt,
    pepper: pepper,
  );

  return result.toPhcHashString();
}