mirror of
https://github.com/S2-/pwgen.git
synced 2025-08-02 17:00:03 +02:00
use crypto.getRandomValues
This commit is contained in:
@@ -3,10 +3,15 @@ function randPassword(length, includeSpecial) {
|
||||
if (includeSpecial) {
|
||||
pwdChars += '°^!"§$%&/()=?`´\\}][{²³€|<>-.,;:*+_µ@~';
|
||||
}
|
||||
let randPassword = Array(length).fill(pwdChars).map(function(x) {
|
||||
return x[Math.floor(Math.random() * x.length)]
|
||||
}).join('');
|
||||
return randPassword;
|
||||
|
||||
let randValues = new Uint32Array(length);
|
||||
let randPwd = '';
|
||||
window.crypto.getRandomValues(randValues);
|
||||
for(i=0; i<length; i++)
|
||||
{
|
||||
randPwd += pwdChars[randValues[i] % pwdChars.length];
|
||||
}
|
||||
return randPwd;
|
||||
}
|
||||
|
||||
function getParams() {
|
||||
|
Reference in New Issue
Block a user