gpt4 book ai didi

string - 没有时间生成随机字符串?

转载 作者:IT王子 更新时间:2023-10-29 01:34:29 24 4
gpt4 key购买 nike

我知道如何使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com