How good are algorithms used in Javascript Math.random() in different browsers? Is it okay to use it for generating salts and one-time passwords?
How many bits from one random I can use?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 atsrc/js/Clipperz/Crypto/PRNG.js), or the Web Crypto API forgetRandomValues