finish method
Finalizes the hash computation and stores the hash state in the provided List
This function completes the hash computation, finalizes the state, and stores the resulting
hash in the provided out
List
Parameters:
out
: The List
Returns the current instance of the hash algorithm.
Implementation
@override
SerializableHash finish(List<int> out) {
if (!_finished) {
final bytesHashed = _bytesHashed;
final left = _bufferLength;
final bitLenHi = (bytesHashed ~/ 0x20000000) & 0xFFFFFFFF;
final bitLenLo = bytesHashed << 3;
final padLength = (bytesHashed % 64 < 56) ? 64 : 128;
_buffer[left] = 0x80;
for (var i = left + 1; i < padLength - 8; i++) {
_buffer[i] = 0;
}
writeUint32BE(bitLenHi, _buffer, padLength - 8);
writeUint32BE(bitLenLo, _buffer, padLength - 4);
_hashBlocks(_temp, _state, _buffer, 0, padLength);
_finished = true;
}
for (var i = 0; i < getDigestLength ~/ 4; i++) {
writeUint32BE(_state[i], out, i * 4);
}
return this;
}