package main import ( "crypto/md5" "fmt" ) func main() { data := []byte("password123") hash := md5.Sum(data) fmt.Printf("MD5 hash of password123: %x\n", hash) }
package main import ( "crypto/sha256" "fmt" ) func main() { data := []byte("secret message") hash := sha256.Sum256(data) fmt.Printf("SHA-256 hash of secret message: %x\n", hash) }This example uses the SHA-256 hash function to generate a hash value for the string "secret message". The `sha256.Sum256()` function takes a byte slice as input and returns an array of bytes representing the hash value. The hash library is a standard library package in Go.