$finalize method

  1. @override
Uint8List $finalize()
override

Finalizes the message digest with the remaining message block, and returns the output as byte array.

Implementation

@override
Uint8List $finalize() {
  // Fill remaining buffer to put the message length at the end
  for (; pos < blockLength; pos++) {
    buffer[pos] = 0;
  }

  // Update with the final block
  $update(buffer, 0, true);

  // Convert the state to 8-bit byte array
  return Uint8List.view(state.buffer).sublist(0, hashLength);
}