getDerivedKey function

KeyDerivator getDerivedKey(
  1. String kdf,
  2. Map<String, dynamic> params
)

getDerivedKey by kdf type

Implementation

KeyDerivator getDerivedKey(String kdf, Map<String, dynamic> params) {
  final salt = (params['salt'] as String).toU8a();
  if (kdf == 'pbkdf2') {
    final c = params['c'];
    final dklen = params['dklen'];
    return _PBDKDF2KeyDerivator(c, salt, dklen);
  } else if (kdf == 'scrypt') {
    final n = params['n'];
    final r = params['r'];
    final p = params['p'];
    final dklen = params['dklen'];
    return _ScryptKeyDerivator(dklen, n, r, p, salt);
  } else {
    throw UnsupportedError('Only pbkdf2 and scrypt are supported.');
  }
}