Make word seperator customizable and add uppercase option

This commit is contained in:
Grant Moyer 2022-03-29 19:10:44 -04:00
parent 3f769ac813
commit b9cac4b68a
2 changed files with 21 additions and 10 deletions

View File

@ -9,7 +9,7 @@
"url": "https://github.com/GrantMoyer/"
},
"resources": {
"js": "gs7QK54TGxiwZIDy9nGplj2zhO1pS6CNyxz9DneKMY9d18EdS7HyxwVf36UKKj34dZB75t6oyKKm5wVFQsqYQ4aE3SisgDvMvCGSe1/+9lxaVP0gs8viPTKJndpOJxqfRHF1X4dJ66Sq5NEBwUfx/9Lf3Yf1kwZ4FGto+s4qp5zSFpWwQi42i61AMRC4dZerS2buLYxkHjcD0G4pK1P5tniSe92M8qGRbtQqNixelNpft2+GdFz7l73+YFBJavIXOhuNnVUVfyY5lf4B0HtG/dzw4nPk0ArdTmWWKuQ43yY3kJUqBolQjJGEOWVLOrHhCiKd+bfDefD2303vGqm3fQ=="
"js": "VostPiiYO18y24hOd0xGA0o2XSLavSMgqd49cH9xj9JDiEzfWEdZPROnOCu4Nz+rqPeL9k5ipftMfcQoDAcOEg8d11aWRkaMT6iX2QPjXh/G8a1a2+YCEpAmoZgZonEMii9hpyocM9G2STu4MEW0qrRQcU3YIDoviEItwe4RlnGVOMH58b80ua1Jbevfo+X0QMLm+UATAwa7VVjU9bao2Dp/L6GMd5KtP5wI3H63x7JU8FAtgJDbK7AFKqSv5qGlbhaT5bPMtQi6po28fP8yWiHZqnnmvVi1g5I28hRAu3fsTAxx+AOKDi6pxdVLCWJWRPidFp2OelP2+VbttQC3IQ=="
},
"licence": "MIT",
"url": "https://github.com/GrantMoyer/keeweb-plugin-passphrase-generator",

View File

@ -18,13 +18,21 @@ Object.defineProperty(GeneratorPresets, 'builtIn', {
title: 'passphrase',
type: 'passphrase',
builtIn: true,
options: [{
name: 'dash',
title: 'Use dash as word seperator',
label: '-',
type: 'checkbox'
}],
dash: true,
options: [
{
name: 'upper',
title: 'Uppercase words',
sample: 'WORD',
label: 'CAP',
type: 'checkbox'
},
{
name: 'seperator',
title: 'Word seperator',
type: 'text'
}
],
seperator: ' ',
length: 6
})
return presets;
@ -37,9 +45,12 @@ PasswordGenerator.generate = function(preset) {
if (typeof preset.length !== 'number' || preset.length < 0) {
return '';
}
const password = Array
let password = Array
.from({length: preset.length}, _ => eff_large_wordlist()[get_random_index()])
.join(preset.dash ? '-' : ' ');
.join(preset.seperator);
if (preset.upper) {
password = password.toUpperCase();
}
return password;
}