I'm using C++11 and the std::hash algorithm. I was wondering, what actual hash implementation is used? I would assume MD5 or SHA, but I can't dig any info from the internets.
Also, I'd like to know the actual returned bit-width of the hash, as I have to store it in MySQL.
Finally, is it preferable to use std::hash, over say some other library such as crypto++ ?
The algorithm chosen for std::hash
is solely implementation dependant. Probably neither MD5 or SHA are used since they would be performance killers for its purpose.
Most implementation will be much more trivial than the above mentioned since there is no cryptographic requirement for std::hash
while MD5 and SHA have been developed for cryptographic purposes.
The requirements of std::hash
are much less strict:
Key
.size_t
that represents the hash value of the parameter.k1
and k2
that are equal, std::hash<Key>()(k1) == std::hash<Key>()(k2)
.k1
and k2
that are not equal, the probability that std::hash<Key>()(k1) == std::hash<Key>()(k2)
should be very small, approaching 1.0/std::numeric_limits<size_t>::max()
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With