mirror of
https://github.com/XFox111/PasswordGeneratorExtension.git
synced 2026-04-22 08:08:01 +03:00
Minor 1.3 (#6)
- Added more special characters for password - Increased minimal password length to 6 characters - Fixed "Do not repeat characters" option - Now passwords always include all types of characters
This commit is contained in:
+26
-5
@@ -2,7 +2,7 @@
|
||||
const upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const lowerCase = upperCase.toLowerCase();
|
||||
const numbers = "1234567890";
|
||||
const specialCharacters = "@#$%";
|
||||
const specialCharacters = "!#$%&*+-=?@^_";
|
||||
const ambiguousCharacters = "{}[]()/\\'\"`~,;:.<>";
|
||||
const similarCharacters = "il1Lo0O";
|
||||
|
||||
@@ -74,7 +74,6 @@ function GeneratePassword(e, useDefaultLength = false)
|
||||
return;
|
||||
}
|
||||
|
||||
let password = "";
|
||||
var pwdLength = settings.length;
|
||||
if (settings.promptForLength && !useDefaultLength)
|
||||
while(true)
|
||||
@@ -83,7 +82,7 @@ function GeneratePassword(e, useDefaultLength = false)
|
||||
if (response === null) // If user clicked 'Cancel'
|
||||
return;
|
||||
|
||||
if (parseInt(response) && response > 1)
|
||||
if (parseInt(response) && response >= 6)
|
||||
{
|
||||
pwdLength = response;
|
||||
break;
|
||||
@@ -98,8 +97,21 @@ function GeneratePassword(e, useDefaultLength = false)
|
||||
return;
|
||||
}
|
||||
|
||||
for (k = 0; k < pwdLength; k++)
|
||||
password += availableCharacters[GetRandomInt(0, availableCharacters.length)]; // Picking random characters
|
||||
do
|
||||
{
|
||||
var password = "";
|
||||
var leftCharacters = availableCharacters;
|
||||
for (k = 0; k < pwdLength; k++)
|
||||
{
|
||||
password += leftCharacters[GetRandomInt(0, leftCharacters.length)]; // Picking random characters
|
||||
if (settings.dontRepeatChars)
|
||||
leftCharacters = leftCharacters.replace(password[k], "");
|
||||
}
|
||||
}
|
||||
while (!((!settings.includeSymbols || ContainsAny(password, specialCharacters)) &&
|
||||
(!settings.includeNumbers || ContainsAny(password, numbers)) &&
|
||||
(!settings.includeLowercase || ContainsAny(password, lowerCase)) &&
|
||||
(!settings.includeUppercase || ContainsAny(password, upperCase))));
|
||||
|
||||
let field = e?.target.previousElementSibling;
|
||||
// Creating a hidden field if called as standalone
|
||||
@@ -132,4 +144,13 @@ function GeneratePassword(e, useDefaultLength = false)
|
||||
function GetRandomInt(min, max)
|
||||
{
|
||||
return Math.floor(Math.random() * (max - min)) + min;
|
||||
}
|
||||
|
||||
function ContainsAny(array1, array2)
|
||||
{
|
||||
for(var k = 0; k < array2.length; k++)
|
||||
if (array1.includes(array2[k]))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "__MSG_name__",
|
||||
"version": "1.2",
|
||||
"version": "1.3",
|
||||
"manifest_version": 2,
|
||||
"description": "__MSG_description__",
|
||||
"author": "__MSG_author__",
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
<h2 loc="generatorOptions">Generator options</h2>
|
||||
<div class="group">
|
||||
<label for="length" style="margin: 5px 0px;"><b loc="length">Password length</b></label>
|
||||
<input id="length" type="number" min="2"/>
|
||||
<input id="length" type="number" min="6"/>
|
||||
<label><span loc="hint">Reccommended password length:</span> <b>16-32</b></label>
|
||||
</div>
|
||||
<div class="group">
|
||||
|
||||
Reference in New Issue
Block a user