encrypt method

String encrypt({
  1. required String inp,
  2. required String iv,
})

Encrypt (with iv) and return in base 64.

If you are using ISAAC, pass a blank String as iv.

Input should be encoded using UTF-8. IV should be encoded using base64.

Implementation

String encrypt({required String inp, required String iv}) {
  var machine = StreamCipher(_stringType);
  var localKey = base64Decode(key);
  var localInput = utf8.encode(inp);
  var ivList = base64Decode(iv);
  var params = ParametersWithIV(
      KeyParameter(Uint8List.fromList(localKey.sublist(0, 32))), ivList);
  machine.init(false, params);
  var inter = machine.process(Uint8List.fromList(localInput));
  return base64.encode(inter);
}