From 42838040d26c225371ef59cad8bcbbb4e3d4f4a7 Mon Sep 17 00:00:00 2001 From: s2 Date: Tue, 21 Nov 2017 09:30:54 +0100 Subject: [PATCH] use crypto.getRandomValues --- src/popup/pwgen.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/popup/pwgen.js b/src/popup/pwgen.js index fed9a76..6b8960d 100644 --- a/src/popup/pwgen.js +++ b/src/popup/pwgen.js @@ -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