macula_content_hasher (macula v0.20.5)
View SourceContent hashing module for Macula content-addressed storage.
Provides cryptographic hashing using BLAKE3 (primary) and SHA256 (fallback). BLAKE3 uses a pure Erlang implementation that can be optimized with NIFs from macula-nifs/ for production use.
Example Usage
%% Hash binary data
Hash = macula_content_hasher:hash(blake3, Data).
%% Verify hash
true = macula_content_hasher:verify(blake3, Data, Hash).
%% Stream hash multiple chunks
Hash = macula_content_hasher:hash_streaming(sha256, [Chunk1, Chunk2]).
Summary
Functions
Hash binary data using the specified algorithm.
Return hash output size in bytes for an algorithm.
Hash a list of binary chunks using streaming (memory efficient).
Decode hex string to binary.
Encode binary to lowercase hex string.
Check if an algorithm is supported.
Return list of supported hash algorithms.
Verify that data matches the expected hash.
Types
Functions
Hash binary data using the specified algorithm.
-spec hash_size(algorithm()) -> pos_integer().
Return hash output size in bytes for an algorithm.
Hash a list of binary chunks using streaming (memory efficient).
Decode hex string to binary.
Encode binary to lowercase hex string.
Check if an algorithm is supported.
-spec supported_algorithms() -> [algorithm()].
Return list of supported hash algorithms.
Verify that data matches the expected hash.