mihomo/common/utils/global_id.go

18 lines
308 B
Go
Raw Permalink Normal View History

2023-06-07 23:03:36 +08:00
package utils
import (
"hash/maphash"
"unsafe"
)
var globalSeed = maphash.MakeSeed()
func GlobalID(material string) (id [8]byte) {
*(*uint64)(unsafe.Pointer(&id[0])) = maphash.String(globalSeed, material)
return
}
2023-06-10 17:35:19 +08:00
func MapHash(material string) uint64 {
return maphash.String(globalSeed, material)
}