deriveKey method

  1. @override
Future<SecretKey> deriveKey({
  1. required SecretKey secretKey,
  2. required List<int> nonce,
  3. List<int> optionalSecret = const <int>[],
  4. List<int> associatedData = const <int>[],
})
override

Calculates output of Argon2id algorithm.

Parameter secretKey is the hashed password, which can have any length.

Parameter nonce is the password salt, which can have any length.

Parameters k and ad are optional additional parameters specified by Argon2. They are usually left empty.

Implementation

@override
Future<SecretKey> deriveKey({
  required SecretKey secretKey,
  required List<int> nonce,
  List<int> optionalSecret = const <int>[],
  List<int> associatedData = const <int>[],
}) async {
  final state = newState();
  try {
    final bytes = await state.deriveKeyBytes(
      password: await secretKey.extractBytes(),
      nonce: nonce,
      optionalSecret: optionalSecret,
      associatedData: associatedData,
    );
    return SecretKey(bytes);
  } finally {
    state.tryReleaseMemory();
  }
}