Files
hi-server/pkg/hash/hash.go
T
shanshanzhong147 197fed7d12
Build docker and publish / build (20.15.1) (push) Failing after 10m56s
Build docker and publish / build (20.15.1) (pull_request) Successful in 8m50s
新功能(#102): 新增邀请记录接口并删除旧邀请销售接口
Co-authored-by: multica-agent <github@multica.ai>
2026-05-27 22:50:16 -07:00

37 lines
736 B
Go

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))
}