更新时间:2021-10-11 15:43:39
如前所述,您做错了,这是非常不安全的.
As it was already mentioned you are doing it wrong and this is super insecure.
func GenerateSecureToken(length int) string {
b := make([]byte, length)
if _, err := rand.Read(b); err != nil {
return ""
}
return hex.EncodeToString(b)
}