decryptInPlace method

void decryptInPlace(
  1. Uint8List data, [
  2. int start = 0,
  3. int? end
])

Decrypts data[start..end) in place; the length must be a multiple of 16.

Implementation

void decryptInPlace(Uint8List data, [int start = 0, int? end]) {
  final stop = RangeError.checkValidRange(start, end, data.length);
  if ((stop - start) % 16 != 0) {
    throw ArgumentError('CBC input must be a multiple of 16 bytes');
  }
  final prev = _prev;
  final block = _block;
  for (var i = start; i < stop; i += 16) {
    block.setRange(0, 16, data, i); // save ciphertext for the next chain
    _cipher.decryptBlock(data, i, data, i);
    for (var j = 0; j < 16; j++) {
      data[i + j] ^= prev[j];
    }
    prev.setAll(0, block);
  }
}