Alternative of Math.random in javascript

Viewed 1480

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));
}
1 Answers
const cryp = window.crypto || window.msCrypto;
var tab= new Uint32Array(1);
cryp.getRandomValues(tab);
Related