Is Math.random() cryptographically secure?(Math.random() 在密码学上是安全的吗?)
问题描述
Javascript Math.random()
在不同浏览器中使用的算法有多好?可以用它来生成盐和一次性密码吗?
How good are algorithms used in Javascript Math.random()
in different browsers? Is it okay to use it for generating salts and one-time passwords?
一个 random
我可以使用多少位?
How many bits from one random
I can use?
推荐答案
不;JavaScript 的 Math.random()
函数不是加密安全的随机数生成器.你最好使用 JavaScript Crypto Library 的 Fortuna 实现,它是一个强大的伪随机数生成器(查看 src/js/Clipperz/Crypto/PRNG.js
)或 getRandomValues
Nope; JavaScript's Math.random()
function is not a cryptographically-secure random number generator. You are better off using the JavaScript Crypto Library's Fortuna implementation which is a strong pseudo-random number generator (have a look at src/js/Clipperz/Crypto/PRNG.js
), or the Web Crypto API for getRandomValues
- 这里有一个详细的解释:javascript的随机性有多值得信赖在各种浏览器中实现?
- 以下是如何生成良好的加密级随机数:在javascript中保护随机数?
这篇关于Math.random() 在密码学上是安全的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Math.random() 在密码学上是安全的吗?


基础教程推荐
- 如何添加到目前为止的天数? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01