package hash import ( "crypto/md5" "fmt" "hash/fnv" "strconv" "github.com/spaolacci/murmur3" ) const invitePeerHashSalt = "ppanel_invite_" + "sales_v1" // Hash returns the hash value of data. func Hash(data []byte) uint64 { return murmur3.Sum64(data) } func InvitePeerHash(userId int64) string { h := fnv.New64a() _, _ = h.Write([]byte(invitePeerHashSalt)) _, _ = h.Write([]byte(strconv.FormatInt(userId, 10))) return fmt.Sprintf("%010d", h.Sum64()%10000000000) } // Md5 returns the md5 bytes of data. func Md5(data []byte) []byte { digest := md5.New() digest.Write(data) return digest.Sum(nil) } // Md5Hex returns the md5 hex string of data. func Md5Hex(data []byte) string { return fmt.Sprintf("%x", Md5(data)) }