mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
23 lines
315 B
Go
23 lines
315 B
Go
|
package hash
|
||
|
|
||
|
import (
|
||
|
"crypto/md5"
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/spaolacci/murmur3"
|
||
|
)
|
||
|
|
||
|
func Hash(data []byte) uint64 {
|
||
|
return murmur3.Sum64(data)
|
||
|
}
|
||
|
|
||
|
func Md5(data []byte) []byte {
|
||
|
digest := md5.New()
|
||
|
digest.Write(data)
|
||
|
return digest.Sum(nil)
|
||
|
}
|
||
|
|
||
|
func Md5Hex(data []byte) string {
|
||
|
return fmt.Sprintf("%x", Md5(data))
|
||
|
}
|