[英]std::hash algorithm and size
I'm using C++11 and the std::hash algorithm. 我正在使用C ++ 11和std :: hash算法。 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.
我会假设MD5或SHA,但我不能从互联网中挖掘任何信息。
Also, I'd like to know the actual returned bit-width of the hash, as I have to store it in MySQL. 另外,我想知道散列的实际返回位宽,因为我必须将它存储在MySQL中。
Finally, is it preferable to use std::hash, over say some other library such as crypto++ ? 最后,是否最好使用std :: hash,比如说其他一些库如crypto ++?
The algorithm chosen for std::hash
is solely implementation dependant. 为
std::hash
选择的算法完全取决于实现。 Probably neither MD5 or SHA are used since they would be performance killers for its purpose. 可能既不使用MD5也不使用SHA,因为它们会成为性能杀手。
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. 大多数实现将比上面提到的要简单得多,因为对于
std::hash
没有加密要求,而MD5和SHA是为加密目的而开发的。
The requirements of std::hash
are much less strict: std::hash
的要求严格得多:
Key
. Key
类型的单个参数。 size_t
that represents the hash value of the parameter. size_t
类型的值,该值表示参数的哈希值。 k1
and k2
that are equal, std::hash<Key>()(k1) == std::hash<Key>()(k2)
. k1
和k2
, 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()
. k1
和k2
, std::hash<Key>()(k1) == std::hash<Key>()(k2)
的概率应该非常小,接近1.0/std::numeric_limits<size_t>::max()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.