decryptHdWallet method
Decrypts an hd wallet
HdWallet hdWallet = new WalletFactory().decryptHdWallet(encryptedWallet, password);
Implementation
HdWallet decryptHdWallet(EncryptedWallet wallet, String password) {
var key = _toSha256I(password);
var iv = hex.decode(wallet.salt.value!);
var message = hex.decode(wallet.cipherText.value!);
CipherParameters params = new PaddedBlockCipherParameters(
new ParametersWithIV(new KeyParameter(key as Uint8List), iv as Uint8List), null);
BlockCipher decryptionCipher = new PaddedBlockCipher("AES/CBC/PKCS7");
decryptionCipher.init(false, params);
String decrypted = utf8.decode(decryptionCipher.process(message as Uint8List));
Map map = jsonDecode(decrypted);
HdWallet hdWallet = HdWallet.fromJson(map as Map<String, dynamic>);
return hdWallet;
}