toDecryptAES static method

String toDecryptAES({
  1. required String encryptedText,
  2. required String aesKey,
})

Implementation

static String toDecryptAES(
    {required String encryptedText, required String aesKey}) {
  final Uint8List encryptedBytesWithSalt = base64.decode(encryptedText);

  final Uint8List encryptedBytes =
      encryptedBytesWithSalt.sublist(0, encryptedBytesWithSalt.length);

  final encrypt.Encrypter encrypter = encrypt.Encrypter(
      encrypt.AES(encrypt.Key.fromUtf8(aesKey), mode: encrypt.AESMode.ecb));

  final String decrypted =
      encrypter.decrypt64(base64.encode(encryptedBytes), iv: iv);

  return decrypted;
}