github.com/lingyao2333/mo-zero@v1.4.1/core/hash/hash.go (about) 1 package hash 2 3 import ( 4 "crypto/md5" 5 "fmt" 6 7 "github.com/spaolacci/murmur3" 8 ) 9 10 // Hash returns the hash value of data. 11 func Hash(data []byte) uint64 { 12 return murmur3.Sum64(data) 13 } 14 15 // Md5 returns the md5 bytes of data. 16 func Md5(data []byte) []byte { 17 digest := md5.New() 18 digest.Write(data) 19 return digest.Sum(nil) 20 } 21 22 // Md5Hex returns the md5 hex string of data. 23 func Md5Hex(data []byte) string { 24 return fmt.Sprintf("%x", Md5(data)) 25 }