| 6 | > - recommendations for a secure hash |
| 7 |
| 8 | If a hash function with unchanging output is needed, please select from one of |
| 9 | the unchanging forever options below. |
| 10 |
| 11 | ## Non-cryptographic |
| 12 |
| 13 | name | 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 |
| 33 | Note 1: While CityHash is not guaranteed unchanging forever, the version used in |
| 34 | Chrome 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 |