argon2 library
Argon2id cryptography wrappers and parametrization.
https://datatracker.ietf.org/doc/html/rfc9106
Turns a password and a salt into key material, made deliberately slow and
memory hungry so guessing passwords is expensive. For stretching a secret
that is already random, see the hkdf library instead.
import 'dart:convert';
import 'package:darkbio_crypto/argon2.dart' as argon2;
import 'package:darkbio_crypto/rand.dart' as rand;
void example() {
// Store the salt and the costs to derive the same key again later
final salt = rand.bytes(16);
final key = argon2.key(
password: utf8.encode('password'),
salt: salt,
time: 3,
memory: 64 * 1024,
threads: 4,
);
assert(key.length == 32);
}