encryptSeedAndSave method

Future<void> encryptSeedAndSave(
  1. String? address,
  2. dynamic seed,
  3. dynamic seedType,
  4. dynamic password,
)

Implementation

Future<void> encryptSeedAndSave(
    String? address, seed, seedType, password) async {
  final String key = Encrypt.passwordToEncryptKey(password);
  final encrypted = await FlutterAesEcbPkcs5.encryptString(seed, key);

  if (seedType == EVMKeyType.mnemonic.toString().split('.')[1]) {
    final mnemonics = Map.from(_storage.encryptedMnemonics.val);
    mnemonics.addAll({address: encrypted});
    _storage.encryptedMnemonics.val = mnemonics;
    return;
  }
  if (seedType == EVMKeyType.privateKey.toString().split('.')[1]) {
    final seeds = Map.from(_storage.encryptedPrivateKeys.val);
    seeds.addAll({address: encrypted});
    _storage.encryptedPrivateKeys.val = seeds;
  }
}