17 lines
206 B
Plaintext
17 lines
206 B
Plaintext
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
|
|
}
|