aesEncrypt method

Future<String> aesEncrypt(
  1. String secretKey,
  2. String value
)

Encrypts value using AES encryption with the provided secretKey.

secretKey is the key used for encryption. value is the data to be encrypted. Returns the encrypted value as a Base64 string.

Implementation

Future<String> aesEncrypt(String secretKey, String value) async {
  final key = Key.fromUtf8(secretKey);
  final iv = IV.fromLength(16);
  final encrypter =
      Encrypter(AES(key, mode: mode ?? AESMode.sic, padding: padding));
  final encrypted = encrypter.encrypt(value, iv: iv);

  await SharedPreferencesWrapper.addMap(
      EncryptionConstants.encryptionMapKey, {accessKey: secretKey});

  return encrypted.base64;
}