Files
virtuallan/pkg/utils/hash.go
lucheng a6bfacb0c2 Fix client ip by get client ip base on username hash
Count username hash, get client ip base on it, it will make ip
fixed base on client login username.
2024-08-09 12:30:26 +08:00

13 lines
168 B
Go

package utils
import (
"hash/fnv"
)
func IdxFromString(step int, str string) int {
h := fnv.New32a()
h.Write([]byte(str))
return int(h.Sum32() % uint32(step))
}