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
- Here is a detailed explanation: How trustworthy is javascript’s random implementation in various browsers?
- Here is how to generate a good crypto grade random number: Secure random numbers in javascript?