encryptBytes function

String encryptBytes(
  1. Uint8List bytes,
  2. String keyText,
  3. String ivText
)

Implementation

String encryptBytes(Uint8List bytes, String keyText, String ivText) {
  keyText = sha512(dart_convert.utf8.encode(keyText)).substring(0, 32);
  ivText = sha512(dart_convert.utf8.encode(ivText)).substring(0, 16);
  final key = encrypt_encrypt.Key.fromUtf8(keyText);
  final iv = encrypt_encrypt.IV.fromUtf8(ivText);
  final encrypter = encrypt_encrypt.Encrypter(encrypt_encrypt.AES(key));
  final encrypted = encrypter.encryptBytes(bytes, iv: iv);
  return encrypted.base64;
}