• Home
Name Date Size #Lines LOC

..--

README.mdD04-Jul-20252.3 KiB4230

hash.ccD04-Jul-20255.7 KiB16397

hash.hD04-Jul-20252.7 KiB8237

hash_perftest.ccD04-Jul-20253 KiB10170

hash_unittest.ccD04-Jul-20253.5 KiB11772

legacy_hash.ccD04-Jul-2025745 2716

legacy_hash.hD04-Jul-2025683 2613

legacy_hash_unittest.ccD04-Jul-20251.1 KiB4029

md5.hD04-Jul-20252.3 KiB7322

md5_boringssl.ccD04-Jul-20251.2 KiB4834

md5_boringssl.hD04-Jul-2025627 2812

md5_constexpr.hD04-Jul-2025951 289

md5_constexpr_internal.hD04-Jul-202510.2 KiB270189

md5_constexpr_unittest.ccD04-Jul-2025913 2613

md5_nacl.ccD04-Jul-20259.2 KiB297194

md5_nacl.hD04-Jul-2025538 2611

md5_unittest.ccD04-Jul-20254.6 KiB172131

sha1.hD04-Jul-20251.3 KiB4525

sha1_boringssl.ccD04-Jul-20251.2 KiB4933

sha1_boringssl.hD04-Jul-2025510 198

sha1_nacl.ccD04-Jul-20253.9 KiB196133

sha1_nacl.hD04-Jul-2025738 4124

sha1_unittest.ccD04-Jul-20254.4 KiB12384

README.md

1# Choosing A Hash Function
2
3> Note: this document is still very much a work-in-progress. Currently missing:
4> - recommendations for hashed containers
5> - recommendations for a better persistent hash
6> - recommendations for a secure hash
7
8If a hash function with unchanging output is needed, please select from one of
9the unchanging forever options below.
10
11## Non-cryptographic
12
13name                                         | input                       | output     | unchanging forever | notes
14---------------------------------------------|-----------------------------|------------|--------------------|-------
15[`Hash()`][hash]                             | overloaded                  | `uint32_t` | no                 | This function is currently being updated to return `size_t`.
16[`PersistentHash()`][persistenthash]         | overloaded                  | `uint32_t` | yes                | Fairly weak but widely used for persisted hashes.
17[`CityHash64()`][cityhash64]                 | `base::span<const uint8_t>` | `uint64_t` | yes (note 1)       | Version 1.0.3. Has some known weaknesses.
18[`CityHash64WithSeed()`][cityhash64withseed] | `base::span<const uint8_t>` | `uint64_t` | yes (note 1)       | Version 1.0.3. Has some known weaknesses.
19
20## Cryptographic
21
22**There are no hashes in `//base` that provide cryptographic security.**
23
24 name                          | input         | output        | unchanging forever | notes
25-------------------------------|---------------|---------------|--------------------|-------
26[`MD5String()`][md5string]     | `std::string` | `std::string` | yes                | **INSECURE**
27[`SHA1HashString`][sha1string] | `std::string` | `std::string` | yes                | **INSECURE**
28
29## Deprecated
30
31> Note: CRC32, Murmur2, and Murmur3 will be listed here.
32
33Note 1: While CityHash is not guaranteed unchanging forever, the version used in
34Chrome is pinned to version 1.0.3.
35
36[hash]: https://cs.chromium.org/chromium/src/base/hash/hash.h?l=26
37[persistenthash]: https://cs.chromium.org/chromium/src/base/hash/hash.h?l=36
38[cityhash64]: https://cs.chromium.org/chromium/src/base/hash/city_v103.h?l=19
39[cityhash64withseed]: https://cs.chromium.org/chromium/src/base/hash/city_v103.h?l=20
40[md5string]: https://cs.chromium.org/chromium/src/base/hash/md5.h?l=74
41[sha1string]: https://cs.chromium.org/chromium/src/base/hash/sha1.h?l=22
42