简体   繁体   中英

Alternative of Math.random in javascript

I am using Math.random() function to get an integer from range of 0 to 'max' number. But According to sonarqube, it is "Security Hotspots" medium issue.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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