saveState method

  1. @override
Blake2bState saveState()
override

Saves the current state of the BLAKE2b hash function for future restoration.

This method captures the current state of the BLAKE2b hash function, including the state vector, buffer, buffer length, counters, flags, whether it represents the last node in a tree, and the padded key (if any), and returns it as a Blake2bState object.

Returns: A Blake2bState object representing the current state of the BLAKE2b instance.

Throws:

  • Exception if the hash function has already been marked as finished.

Implementation

@override
Blake2bState saveState() {
  if (_finished) {
    throw const MessageException("blake2b: cannot save finished state");
  }

  return Blake2bState(
    state: List<int>.from(_state, growable: false),
    buffer: List<int>.from(_buffer, growable: false),
    bufferLength: _bufferLength,
    ctr: List<int>.from(_ctr, growable: false),
    flag: List<int>.from(_flag, growable: false),
    lastNode: _lastNode,
    paddedKey: _paddedKey != null ? List<int>.from(_paddedKey!) : null,
    initialState: List<int>.from(_initialState, growable: false),
  );
}