7 releases
0.4.3 | Nov 4, 2022 |
---|---|
0.4.2 | Jun 22, 2022 |
0.4.1 | Mar 29, 2022 |
0.3.3 | Jun 22, 2022 |
0.3.1 | Feb 4, 2022 |
#1076 in Algorithms
2,604 downloads per month
Used in 3 crates
(2 directly)
45KB
914 lines
This crate provides a stable, structured hash with backward compatibility features. What does that mean?
- Stable: The value of the hash will not change across minor versions of this library, even when the compiler, process, architecture, or std lib does change.
- Structured: Hashes structs, rather than streams
- Backward compatibility: It is possible to make limited changes to a struct's schema without changing the value of the hash. One change is that you can add new fields. This is accomplished by skipping default values when hashing. For example, the values None, 0, false, and vec![] do not contribute to the hash. Therefore structs Old { a: 1 } and New { a: 1, b: None } hash to the same value. Another feature enabling backward compatibility is that the size of an integer can be increased without changing the value. For example, Old { a: 1u16 } and New { a: 1u32 } hash to the same value. Note that even though two structs with different schemas are allowed to collide, two structs with the same schema never collide (where collide is defined as contribution to the hash is injective in respect to the encoding. It is still possible to find collisions in the final output, especially for the non-cryptographic version)
Dependencies
~3MB
~73K SLoC