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