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) {
  var salt = (params['salt'] as String).toU8a();
  if (kdf == 'pbkdf2') {
    var c = params['c'];
    var dklen = params['dklen'];
    return _PBDKDF2KeyDerivator(c, salt, dklen);
  } else if (kdf == 'scrypt') {
    var n = params['n'];
    var r = params['r'];
    var p = params['p'];
    var dklen = params['dklen'];
    return _ScryptKeyDerivator(dklen, n, r, p, salt);
  } else {
    throw ArgumentError('Only pbkdf2 and scrypt are supported');
  }
}