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) uint64

Parameters & Attributes

NameTypeDescription
seedSeedInitialized process-local seed from MakeSeed or Hash.Seed.
sstringString 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())}
Go Reference