decrypt method

String decrypt({
  1. required String enc,
  2. required String iv,
})

Decrypt (with iv) and return original String.

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

encrypted and iv should be encoded using base64. Encrypted should have been generated using the parameters specified in encrypt.

Implementation

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