encrypt method

String encrypt({
  1. required String data,
  2. String? newKey,
  3. String? iv,
})

Implementation

String encrypt({
  required String data,
  String? newKey,
  String? iv,
}) {
  iv ??= defaultIv;
  newKey ??= defaultKey;

  final encrypter = Encrypter(
    AES(
      Key.fromUtf8(newKey),
      mode: AESMode.ctr,
    ),
  );

  return encrypter.encrypt(data, iv: IV.fromBase64(iv)).base64;
}