buildKey function

Key buildKey(
  1. String masterPassword
)

Implementation

Key buildKey(String masterPassword) {
  // use masterPassword to generate Key
  // convert masterPassword into md5 hash
  // convert md5 hash into 32 bytes
  final mp = md5.convert(utf8.encode(masterPassword)).bytes;
  final mp32 = mp.sublist(0, 16) + mp.sublist(0, 16).reversed.toList();
  final b64 = base64.encode(mp32);

  return encrypt.Key.fromBase64(b64);
}