deriveKeys method

Future<Map<String, String>> deriveKeys(
  1. String password,
  2. int version,
  3. String salt
)

Implementation

Future<Map<String, String>> deriveKeys(
    String password, int version, String salt) async {
  final k = HEX
      .encode(pbkdf2(utf8.encode(password), utf8.encode(salt), 200000, 64))
      .toLowerCase();
  return (version == 2)
      ? {
          'masterKey': k.substring(0, 64),
          'password': HEX
              .encode(
                  crypto.sha512.convert(utf8.encode(k.substring(64))).bytes)
              .toLowerCase()
        }
      : {'masterKey': k, 'password': k};
}