update method
Updates the hash computation with the given data.
Parameters:
data: Containing the data to be hashed.
Implementation
@override
SerializableHash update(List<int> data, {int? length}) {
if (_finished) {
throw CryptoException.failed(
"SHA512.update",
reason: "State was finished.",
);
}
int dataPos = 0;
int dataLength = length ?? data.length;
_bytesHashed += dataLength;
if (_bufferLength > 0) {
while (_bufferLength < getBlockSize && dataLength > 0) {
_buffer[_bufferLength++] = data[dataPos++] & BinaryOps.mask8;
dataLength--;
}
if (_bufferLength == getBlockSize) {
_hashBlocks(
_tempHi,
_tempLo,
_stateHi,
_stateLo,
_buffer,
0,
getBlockSize,
);
_bufferLength = 0;
}
}
if (dataLength >= getBlockSize) {
dataPos = _hashBlocks(
_tempHi,
_tempLo,
_stateHi,
_stateLo,
data,
dataPos,
dataLength,
);
dataLength %= getBlockSize;
}
while (dataLength > 0) {
_buffer[_bufferLength++] = data[dataPos++] & BinaryOps.mask8;
dataLength--;
}
return this;
}