tree: 7c3f0751b5678d41f951e74387a57f53aeba609f [path history] [tgz]
  1. hash.cc
  2. hash.h
  3. hash_perftest.cc
  4. hash_unittest.cc
  5. legacy_hash.cc
  6. legacy_hash.h
  7. legacy_hash_unittest.cc
  8. md5.h
  9. md5_boringssl.cc
  10. md5_boringssl.h
  11. md5_constexpr.h
  12. md5_constexpr_internal.h
  13. md5_constexpr_unittest.cc
  14. md5_nacl.cc
  15. md5_nacl.h
  16. md5_unittest.cc
  17. README.md
  18. sha1.h
  19. sha1_boringssl.cc
  20. sha1_boringssl.h
  21. sha1_nacl.cc
  22. sha1_nacl.h
  23. sha1_unittest.cc
base/hash/README.md

Choosing A Hash Function

Note: this document is still very much a work-in-progress. Currently missing:

  • recommendations for hashed containers
  • recommendations for a better persistent hash
  • recommendations for a secure hash

If a hash function with unchanging output is needed, please select from one of the unchanging forever options below.

Non-cryptographic

nameinputoutputunchanging forevernotes
Hash()overloadeduint32_tnoThis function is currently being updated to return size_t.
PersistentHash()overloadeduint32_tyesFairly weak but widely used for persisted hashes.
CityHash64()base::span<const uint8_t>uint64_tyes (note 1)Version 1.0.3. Has some known weaknesses.
CityHash64WithSeed()base::span<const uint8_t>uint64_tyes (note 1)Version 1.0.3. Has some known weaknesses.

Cryptographic

There are no hashes in //base that provide cryptographic security.

nameinputoutputunchanging forevernotes
MD5String()std::stringstd::stringyesINSECURE
SHA1HashStringstd::stringstd::stringyesINSECURE

Deprecated

Note: CRC32, Murmur2, and Murmur3 will be listed here.

Note 1: While CityHash is not guaranteed unchanging forever, the version used in Chrome is pinned to version 1.0.3.