mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-26 07:39:04 +02:00
Remove "binning" from password generation
This commit is contained in:
parent
a65d7208c7
commit
b1da50133b
|
@ -1,6 +1,5 @@
|
||||||
import kdbxweb from 'kdbxweb';
|
import kdbxweb from 'kdbxweb';
|
||||||
import { phonetic } from 'util/generators/phonetic';
|
import { phonetic } from 'util/generators/phonetic';
|
||||||
import { shuffle } from 'util/fn';
|
|
||||||
|
|
||||||
const PasswordGenerator = {
|
const PasswordGenerator = {
|
||||||
charRanges: {
|
charRanges: {
|
||||||
|
@ -39,14 +38,17 @@ const PasswordGenerator = {
|
||||||
if (!ranges.length) {
|
if (!ranges.length) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
const pool = [];
|
||||||
|
for (let i = 0; i < ranges.length; i++) {
|
||||||
|
pool.push(...ranges[i]);
|
||||||
|
}
|
||||||
const randomBytes = kdbxweb.Random.getBytes(opts.length);
|
const randomBytes = kdbxweb.Random.getBytes(opts.length);
|
||||||
const chars = [];
|
const chars = [];
|
||||||
for (let i = 0; i < opts.length; i++) {
|
for (let i = 0; i < opts.length; i++) {
|
||||||
const range = ranges[i % ranges.length];
|
|
||||||
const rand = Math.round(Math.random() * 1000) + randomBytes[i];
|
const rand = Math.round(Math.random() * 1000) + randomBytes[i];
|
||||||
chars.push(range[rand % range.length]);
|
chars.push(pool[rand % pool.length]);
|
||||||
}
|
}
|
||||||
return shuffle(chars).join('');
|
return chars.join('');
|
||||||
},
|
},
|
||||||
|
|
||||||
generateMac() {
|
generateMac() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user