File: README.md

package info (click to toggle)
chromium 120.0.6099.224-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,112,112 kB
  • sloc: cpp: 32,907,025; ansic: 8,148,123; javascript: 3,679,536; python: 2,031,248; asm: 959,718; java: 804,675; xml: 617,256; sh: 111,417; objc: 100,835; perl: 88,443; cs: 53,032; makefile: 29,579; fortran: 24,137; php: 21,162; tcl: 21,147; sql: 20,809; ruby: 17,735; pascal: 12,864; yacc: 8,045; lisp: 3,388; lex: 1,323; ada: 727; awk: 329; jsp: 267; csh: 117; exp: 43; sed: 37
file content (41 lines) | stat: -rw-r--r-- 2,371 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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

name                                         | input                       | output     | unchanging forever | notes
---------------------------------------------|-----------------------------|------------|--------------------|-------
[`Hash()`][hash]                             | overloaded                  | `uint32_t` | no                 | This function is currently being updated to return `size_t`.
[`PersistentHash()`][persistenthash]         | overloaded                  | `uint32_t` | yes                | Fairly weak but widely used for persisted hashes.
[`CityHash64()`][cityhash64]                 | `base::span<const uint8_t>` | `uint64_t` | yes (note 1)       | Version 1.0.3. Has some known weaknesses.
[`CityHash64WithSeed()`][cityhash64withseed] | `base::span<const uint8_t>` | `uint64_t` | yes (note 1)       | Version 1.0.3. Has some known weaknesses.

## Cryptographic

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

 name                          | input         | output        | unchanging forever | notes
-------------------------------|---------------|---------------|--------------------|-------
[`MD5String()`][md5string]     | `std::string` | `std::string` | yes                | **INSECURE**
[`SHA1HashString`][sha1string] | `std::string` | `std::string` | yes                | **INSECURE**

## 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.

[hash]: https://cs.chromium.org/chromium/src/base/hash/hash.h?l=26
[persistenthash]: https://cs.chromium.org/chromium/src/base/hash/hash.h?l=36
[cityhash64]: https://cs.chromium.org/chromium/src/base/hash/city_v103.h?l=19
[cityhash64withseed]: https://cs.chromium.org/chromium/src/base/hash/city_v103.h?l=20
[md5string]: https://cs.chromium.org/chromium/src/base/hash/md5.h?l=74
[sha1string]: https://cs.chromium.org/chromium/src/base/hash/sha1.h?l=22