Standard library / hash/maphash
hash/maphash.String()
Hash the bytes of a string under an initialized seed without needing a byte-slice conversion. This is not a cryptographic authentication primitive. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func String(seed Seed, s string) uint64Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| seed | Seed | Initialized process-local seed from MakeSeed or Hash.Seed. |
| s | string | String whose bytes are hashed. |
Return Value
uint64
64-bit unsigned result.
Working Example
Example Snippetgo
package main
import ( "fmt" "hash/maphash")
func main() { s := maphash.MakeSeed() var h maphash.Hash h.SetSeed(s) h.WriteString("Go") fmt.Println(maphash.String(s, "Go") == h.Sum64())}