Hash functions now accept an option set

- This avoids having multiple `init()` functions for every combination
of optional parameters
- The API is consistent across all hash functions
- New options can be added later without breaking existing applications.
  For example, this is going to come in handy if we implement parallelization
  for BLAKE2 and BLAKE3.
- We don't have a mix of snake_case and camelCase functions any more, at
least in the public crypto API

Support for BLAKE2 salt and personalization (more commonly called context)
parameters have been implemented by the way to illustrate this.
This commit is contained in:
Frank Denis
2020-08-21 00:51:14 +02:00
parent adf3d00e87
commit fc55cd458a
15 changed files with 194 additions and 149 deletions

View File

@@ -26,7 +26,7 @@ pub fn hashSrc(src: []const u8) SrcHash {
std.mem.copy(u8, &out, src);
std.mem.set(u8, out[src.len..], 0);
} else {
std.crypto.hash.Blake3.hash(src, &out);
std.crypto.hash.Blake3.hash(src, &out, .{});
}
return out;
}