encryptData function

String encryptData(
  1. String data,
  2. String secretKey
)

Implementation

String encryptData(String data, String secretKey) {
  final key = encrypt.Key.fromUtf8(
      secretKey.padRight(16, '0').substring(0, 16)); // Ensure 16-byte key
  final encrypter =
      encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.ecb));
  final encrypted = encrypter.encrypt(data,
      iv: encrypt.IV.fromLength(16)); // ECB mode doesn't use IV

  return base64Encode(encrypted.bytes);
}