PBKDF2 constructor
Create a PBKDF2 instance with a MAC instance.
Implementation
factory PBKDF2(
MACHash mac,
int iterations, {
List<int>? salt,
int? keyLength,
}) {
keyLength ??= _defaultKeyLength;
salt ??= randomBytes(_defaultSaltLength);
// validate parameters
if (iterations < 1) {
throw StateError('The iterations must be at least 1');
}
if (iterations > 0x7FFFFFFF) {
throw StateError('The iterations must be less than 2^31');
}
if (keyLength < 1) {
throw StateError('The keyLength must be at least 1');
}
// create instance
return PBKDF2._(
algo: mac,
salt: salt,
iterations: iterations,
derivedKeyLength: keyLength,
);
}