package main import ( "crypto/md5" "fmt" ) func main() { data := []byte("example data") hash := md5.Sum(data) fmt.Printf("%x\n", hash) // Reset the hash to its initial state md5.Reset() newdata := []byte("new example data") newhash := md5.Sum(newdata) fmt.Printf("%x\n", newhash) }
package main import ( "crypto/sha256" "fmt" ) func main() { data := []byte("example data") hash := sha256.Sum256(data) fmt.Printf("%x\n", hash) // Reset the hash to its initial state sha256.Reset() newdata := []byte("new example data") newhash := sha256.Sum256(newdata) fmt.Printf("%x\n", newhash) }In this example, we create a SHA256 hash for the data "example data". We then reset the hash and create a new hash for the data "new example data". The Go Hash Reset function is part of the Hash interface in the Go standard library. It can be used with any hash function that implements this interface.