saveState method

  1. @override
SHA512State saveState()
override

Saves the current hash computation state into a serializable state object.

This method saves the current state of the hash computation, including the data buffer, hash state, and etc, into a serializable state object. The saved state can be later restored using the restoreState method.

Returns a HashState object containing the saved state information.

Implementation

@override
SHA512State saveState() {
  if (_finished) {
    throw const MessageException("SHA256: cannot save finished state");
  }
  return SHA512State(
    stateHi: List<int>.from(_stateHi, growable: false),
    stateLo: List<int>.from(_stateLo, growable: false),
    buffer: (_bufferLength > 0) ? List<int>.from(_buffer) : null,
    bufferLength: _bufferLength,
    bytesHashed: _bytesHashed,
  );
}