复制项目
This commit is contained in:
16
pkg/util/hashutil/id.go
Normal file
16
pkg/util/hashutil/id.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package hashutil
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func IdHash(ids []string) uint64 {
|
||||
if len(ids) == 0 {
|
||||
return 0
|
||||
}
|
||||
data, _ := json.Marshal(ids)
|
||||
sum := md5.Sum(data)
|
||||
return binary.BigEndian.Uint64(sum[:])
|
||||
}
|
||||
Reference in New Issue
Block a user