将 rand() 用于加密不安全的随机数是否可以接受? [英] Is it acceptable to use rand() for cryptographically insecure random numbers?

查看:24
本文介绍了将 rand() 用于加密不安全的随机数是否可以接受?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 C 标准库的 rand() 函数用于 必须是加密安全的随机数是否可以接受?如果是这样,还有更好的选择吗?如果不是,应该使用什么?

Is it acceptable to use the C standard library's rand() function for random numbers that do not have to be cryptographically secure? If so, are there still better choices? If not, what should be used?

当然,我假设关于偏斜的常见警告适用.

推荐答案

是的,使用 rand() 获取伪随机数很好.事实上,这就是 rand() 的全部意义所在.对于可以确定性的简单任务,为了简单起见,您甚至可以设置系统时钟.

Yes, it is fine to use rand() to get pseudo-random numbers. In fact, that is the whole point of rand(). For simple tasks, where it is OK to be deterministic, you can even seed the system clock for simplicity.

这篇关于将 rand() 用于加密不安全的随机数是否可以接受?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆