Documentation ¶
Overview ¶
Package hashx implements allocation-free standard hashing functions
Index ¶
- func CRC16(b []byte) (crc uint16)
- func CRC16String(s string) (crc uint16)
- func Fnv32a(b []byte) uint32
- func Fnv32aString(s string) uint32
- func Fnv64a(b []byte) uint64
- func Fnv64aString(s string) uint64
- func MM128(data []byte) (h1, h2 uint64)
- func MM128String(data string) (h1, h2 uint64)
- func MM32(data []byte) (h1 uint32)
- func MM32String(data string) (h1 uint32)
- func MM64(data []byte) uint64
- func MM64String(data string) uint64
- func XX32(input []byte, seed uint32) uint32
- func XX32String(input string, seed uint32) uint32
- func XX64(data []byte, seed uint64) uint64
- func XX64String(data string, seed uint64) uint64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CRC16 ¶
CRC16 calculates a CRC-16 according to CCITT standards. It returns 0 on empty input.
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(CRC16(p))
Output: 13678
func CRC16String ¶
CRC16String calculates a CRC-16 from a string according to CCITT standards. It returns 0 on empty input.
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(CRC16String(s))
Output: 13678
func Fnv32a ¶
Fnv32a calculates 32-bit FNV-1a hash. It returns 0 on empty input (nil or empty byte slice).
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(Fnv32a(p))
Output: 1538131534
func Fnv32aString ¶
Fnv32aString calculates 32-bit FNV-1a hash. It returns 0 on empty input (nil or empty strings).
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(Fnv32aString(s))
Output: 1538131534
func Fnv64a ¶
Fnv64a calculates 64-bit FNV-1a hash. It returns 0 on empty input.
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(Fnv64a(p))
Output: 15849972611371769326
func Fnv64aString ¶
Fnv64aString calculates 64-bit FNV-1a hash. It returns 0 on empty input.
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(Fnv64aString(s))
Output: 15849972611371769326
func MM128 ¶
MM128 calculates 128-bit murmur3 hash.
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(MM128(p))
Output: 7376845339986439510 5610010571125513187
func MM128String ¶
MM128String calculates 128-bit murmur3 hash.
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(MM128String(s))
Output: 7376845339986439510 5610010571125513187
func MM32 ¶
MM32 calculates 32-bit murmur3 hash.
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(MM32(p))
Output: 409351655
func MM32String ¶
MM32String calculates 32-bit murmur3 hash.
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(MM32String(s))
Output: 409351655
func MM64 ¶
MM64 calculates 64-bit murmur3 hash.
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(MM64(p))
Output: 7376845339986439510
func MM64String ¶
MM64String calculates 64-bit murmur3 hash.
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(MM64String(s))
Output: 7376845339986439510
func XX32 ¶
XX32 returns the 32bit xxHash value.
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(XX32(p, 0))
Output: 119031159
func XX32String ¶ added in v0.9.1
XX32String returns the 32bit xxHash value.
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(XX32String(s, 0))
Output: 119031159
func XX64 ¶
XX64 returns the 64bit xxHash value.
Example ¶
p := []byte("One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.") fmt.Println(XX64(p, 0))
Output: 2399806787706828701
func XX64String ¶ added in v0.9.1
XX64String returns the 64bit xxHash value.
Example ¶
s := "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." fmt.Println(XX64String(s, 0))
Output: 2399806787706828701
Types ¶
This section is empty.