Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the window.crypto.getRandomValues() method
Re:Is this password-generator sufficient?
by cratermoon on Saturday August 19, 2023 @12:23PM
(#37190361)
Please, please, if you're going to go into anything related to security, read up on the subject. It's ok to do things like to learn, but putting them into production is unwise. See, for example, https://www.schneier.com/crypto-gram/archives/1998/1015.html... and read up, with books like Applied Cryptography. Read a few DefCon papers or videos.
Math.random() does not provide cryptographically secure random numbers. Do not use them for anything related to security. Use the Web Crypto API instead, and more precisely the window.crypto.getRandomValues() method