goProject/trunk/goutil/stringUtil/hash.go

17 lines
206 B
Go
Raw Normal View History

2025-01-06 16:01:02 +08:00
package stringUtil
import (
"hash/crc32"
)
// HashCode 获取字符串对应的hashCode值
func HashCode(s string) int {
v := int(crc32.ChecksumIEEE([]byte(s)))
if v < 0 {
return -v
}
return v
}