aesDecrypt function

String aesDecrypt(
  1. String encryptedText,
  2. String key
)

Implementation

String aesDecrypt(String encryptedText, String key) {
  final keyBytes = utf8.encode(key);
  final paddedKey = Uint8List.fromList(List<int>.from(keyBytes)
    ..addAll(List<int>.filled(32 - keyBytes.length, 0)));
  final encrypterKey = encrypt.Key(paddedKey);
  final iv = encrypt.IV(Uint8List.fromList(List<int>.filled(16, 0)));
  final encrypter = encrypt.Encrypter(encrypt.AES(encrypterKey));

  final decrypted = encrypter
      .decrypt(encrypt.Encrypted(base64.decode(encryptedText)), iv: iv);
  return decrypted;
}