Better password generator

This commit is contained in:
Alan Friedman 2016-01-13 13:50:48 -05:00
parent c2448a7e4e
commit d79c5ada53

View File

@ -62,8 +62,7 @@ $(function() {
} else { } else {
fs(window.TEMPORARY, fs(window.TEMPORARY,
100, 100,
log.bind(log, "WARNING: Your browser is not in incognito mode!"), log.bind(log, "WARNING: Your browser is not in incognito mode!"));
log.bind(log, "Your browser is in incognito mode."));
} }
// If the username is valid // If the username is valid
@ -273,7 +272,7 @@ $(function() {
}); });
$genKey.click(function () { $genKey.click(function () {
let key = (Math.random() * Math.random()).toString(36).substring(7); let key = generatePassword();
updateKeyVal(key); updateKeyVal(key);
}); });
@ -286,7 +285,7 @@ $(function() {
users = data.users; users = data.users;
let key = (Math.random() * Math.random()).toString(36).substring(7); let key = generatePassword();
if (data.numUsers > 1) { if (data.numUsers > 1) {
$('#join-modal').modal('show'); $('#join-modal').modal('show');
@ -499,4 +498,14 @@ $(function() {
typing = false; typing = false;
}); });
function generatePassword() {
let length = 16;
const charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let retVal = "";
for (var i = 0, n = charset.length; i < length; ++i) {
retVal += charset.charAt(Math.floor(Math.random() * n));
}
return retVal;
}
}); });