散列取模增加参数

This commit is contained in:
gotoeasy 2022-06-28 16:46:12 +08:00
parent c13ee8216a
commit 1df8f3da7c

View File

@ -121,8 +121,8 @@ func PathSeparator() string {
}
// 字符串哈希处理后取模(余数)返回值最大不超过mod值
func HashAndMod(str string, mod uint32) string {
txt := "添油" + str + "加醋"
func HashAndMod(str string, mod uint32, prefix string) string {
txt := prefix + "_" + str
return fmt.Sprint(crc32.ChecksumIEEE(StringToBytes(txt)) % mod)
}