我知道如何使用 Runes & seeding rand.Init 和 time.UnixNano()
在 go 中生成随机字符串。我的问题是,是否可以(使用 stdlib)在不使用当前时间戳(安全)的情况下播种 rand?
此外,我想问的是,因为仅仅依靠时间来为敏感操作生成随机字符串是不安全的/漏洞吗?
最佳答案
对于敏感操作,请使用 crypto/rand
而不是 math/rand
:
Package [crypto/] rand implements a cryptographically secure random number generator.
请注意,您不需要(您不能)种子 crypto/rand
。
关于string - 没有时间生成随机字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53871104/