【问题标题】:Alternative of Math.random in javascriptjavascript 中 Math.random 的替代方案
【发布时间】:2021-07-02 08:57:04
【问题描述】:

我正在使用 Math.random() 函数来获取从 0 到“最大”数范围内的整数。 但根据 sonarqube 的说法,这是“安全热点”中等问题。

private getRandomInt(max) {
    return Math.floor(Math.random() * Math.floor(max));
}

【问题讨论】:

标签: javascript node.js


【解决方案1】:
const cryp = window.crypto || window.msCrypto;
var tab= new Uint32Array(1);
cryp.getRandomValues(tab);

【讨论】:

    猜你喜欢
    • 2017-04-05
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-19
    相关资源
    最近更新 更多