PHP
·
发表于 5年以前
·
阅读量:8327
var _randomKey = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890"
func randomKey(length int) string {
result := ""
r := rand.New(rand.NewSource(time.Now().Unix()))
rkl := len(_randomKey)
for i := 0; i < length; i++ {
randInt := r.Intn(rkl)
result = result + _randomKey[randInt:randInt+1]
}
return result
}