dsaob80228 2018-12-20 14:58
浏览 63
已采纳

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

I know how to generate a random string in go using Runes & seeding rand.Init with time.UnixNano(). My question is, is it possible (with the stdlib) to seed rand without using the current timestamp (secure)?

Furthermore, I ask because isn't just relying on time to generate a random string for a sensitive operation insecure/a vulnerability?

  • 写回答

2条回答 默认 最新

  • dtqu72830 2018-12-20 15:00
    关注

    For sensitive operations use crypto/rand instead of math/rand:

    Package [crypto/] rand implements a cryptographically secure random number generator.

    Note that you don't need (you can't) seed crypto/rand.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题