processBytes method

  1. @override
void processBytes(
  1. Uint8List inp,
  2. int inpOff,
  3. int len,
  4. Uint8List out,
  5. int outOff,
)
override

Process len bytes of data given by inp and starting at offset inpOff. The resulting cipher text is put in out beginning at position outOff.

Implementation

@override
void processBytes(
    Uint8List inp, int inpOff, int len, Uint8List out, int outOff) {
  if ((inpOff + len) > inp.length) {
    throw ArgumentError('input buffer too short');
  }

  if ((outOff + len) > out.length) {
    throw ArgumentError('output buffer too short');
  }

  for (var i = 0; i < len; i++) {
    _x = (_x + 1) & 0xff;
    _y = (_engineState![_x] + _y) & 0xff;

    // swap
    var tmp = _engineState![_x];
    _engineState![_x] = _engineState![_y];
    _engineState![_y] = tmp;

    // xor
    out[i + outOff] = inp[i + inpOff] ^
        _engineState![(_engineState![_x] + _engineState![_y]) & 0xff];
  }
}