简体   繁体   English

javascript 中 Math.random 的替代方案

[英]Alternative of Math.random in javascript

I am using Math.random() function to get an integer from range of 0 to 'max' number.我正在使用 Math.random() 函数来获取从 0 到“最大”数的整数。 But According to sonarqube, it is "Security Hotspots" medium issue.但是根据sonarqube,这是“安全热点”中的问题。

private getRandomInt(max) {
    return Math.floor(Math.random() * Math.floor(max));
}
const cryp = window.crypto || window.msCrypto;
var tab= new Uint32Array(1);
cryp.getRandomValues(tab);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM