digest::Digest::update behaviour with different array sizes
⚓ Rust 📅 2026-03-09 👤 surdeus 👁️ 1I am unsure about the behavior of the update function on the digest::Digest trait. Is it guaranteed that passing in the data in different chunks still results in the same result? I would expect it to be that way, but I didn't find any confirmation for this in the docs. Instead, the first section of the standard library Hasher trait doc mentions that we should not assume that
hasher.write(&[1, 2]);
hasher.write(&[3, 4, 5, 6]);
should not be assumed to result in the same hash as
hasher.write(&[1, 2, 3, 4]);
hasher.write(&[5, 6]);
So, can I just pass in data into the digest::Digest::update function as it arrives or do I have to control the chunksize?
6 posts - 4 participants
🏷️ Rust_feed