Use all the possible values for a unicode mapping

This commit is contained in:
Kevin F 2022-05-10 13:02:21 -05:00
parent caae505777
commit 876e6d9015
2 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,7 @@ let usingUnicode = function(result){
} }
} }
let doUnicode = browser.storage.sync.get("keyboardprivacyunicode"); let doUnicode = browser.storage.sync.get("keyboardprivacyunicode");
doUnicode.then(usingUnicode, onError); doUnicode.then(usingUnicode, onError);

View File

@ -1,3 +1,16 @@
let randNum = function(minValue, maxValue){
let buf = new Uint8Array(1)
while (true){
window.crypto.getRandomValues(buf);
if (buf[0] <= maxValue && buf[0] >= minValue){
break;
}
buf = new Uint8Array(1);
}
return buf[0];
}
let getUnicode = function(input){ let getUnicode = function(input){
const uc = const uc =
{ {
@ -103,7 +116,7 @@ let getUnicode = function(input){
output += element output += element
} }
else{ else{
output += uc[element][0] output += uc[element][randNum(0, uc[element].length - 1)]
} }
}) })
return output return output