tree: 9a0725a976319c116eb1cd5d60f8b1e27761e293 [path history] [tgz]
  1. README.md
  2. hash.cc
  3. hash.h
  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. sha1.cc
  18. sha1.h
  19. sha1_boringssl.cc
  20. sha1_perftest.cc
  21. 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.