Can hash_map::DefaultHasher be used as a checksum?

In other words is its concrete implementation a subject to change? Currently it uses SipHasher13.

No, you can't depend on a specific hashing algorithm being used for DefaultHasher:

The internal algorithm is not specified, and so it and its hashes should not be relied upon over releases.


I'll add that even if you write your own deterministic Hasher, you still shouldn't use Hash as a checksum.


Serialization formats intended to be portable between platforms or compiler versions should either avoid encoding hashes or only rely on Hash and Hasher implementations that provide additional guarantees.

Importantly, the implementations of Hash aren't guaranteed to call the same methods on Hasher across compiler versions. For example, I'm working on changes that will affect how [_]s and strs are hashed, which might change the checksums you calculate.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.