Function update [src]
Add input to the hash state. This can be called any number of times.
Prototype
pub fn update(self: *Blake3, input_slice: []const u8) void
Parameters
self: *Blake3
input_slice: []const u8
Source
pub fn update(self: *Blake3, input_slice: []const u8) void {
var input = input_slice;
while (input.len > 0) {
// If the current chunk is complete, finalize it and reset the
// chunk state. More input is coming, so this chunk is not ROOT.
if (self.chunk_state.len() == CHUNK_LEN) {
const chunk_cv = self.chunk_state.output().chainingValue();
const total_chunks = self.chunk_state.chunk_counter + 1;
self.addChunkChainingValue(chunk_cv, total_chunks);
self.chunk_state = ChunkState.init(self.key, total_chunks, self.flags);
}
// Compress input bytes into the current chunk state.
const want = CHUNK_LEN - self.chunk_state.len();
const take = @min(want, input.len);
self.chunk_state.update(input[0..take]);
input = input[take..];
}
}