setKey method
Implementation
void setKey(Uint8List keyBytes) {
_workingKey = keyBytes;
_x = 0;
_y = 0;
_engineState ??= Uint8List(STATE_LENGTH);
// reset the state of the engine
for (var i = 0; i < STATE_LENGTH; i++) {
_engineState![i] = i;
}
var i1 = 0;
var i2 = 0;
for (var i = 0; i < STATE_LENGTH; i++) {
i2 = ((keyBytes[i1] & 0xff) + _engineState![i] + i2) & 0xff;
// do the byte-swap inline
var tmp = _engineState![i];
_engineState![i] = _engineState![i2];
_engineState![i2] = tmp;
i1 = (i1 + 1) % keyBytes.length;
}
}