Math.random() 在密码学上是安全的吗? [英] Is Math.random() cryptographically secure?

查看:28
本文介绍了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

这篇关于Math.random() 在密码学上是安全的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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