問題描述
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() 在密碼學上是安全的嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!