|
@@ -90,11 +90,22 @@ function randomNum(start, end) {
|
|
|
|
|
|
//字母随机
|
|
|
function randomAlp(arr, count) {
|
|
|
- let shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
|
|
|
+
|
|
|
+ let shuffled = arr.slice(0)
|
|
|
+ let i = arr.length
|
|
|
+ if(count>i){
|
|
|
+ i = count
|
|
|
+ }
|
|
|
+ let min = i - count, temp, index;
|
|
|
while (i-- > min) {
|
|
|
- index = Math.floor((i + 1) * Math.random());
|
|
|
+ index = Math.floor((arr.length) * Math.random());
|
|
|
temp = shuffled[index];
|
|
|
- shuffled[index] = shuffled[i];
|
|
|
+ if( shuffled[i]){
|
|
|
+ shuffled[index] = shuffled[i];
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ shuffled[index] = shuffled[index]
|
|
|
+ }
|
|
|
shuffled[i] = temp;
|
|
|
}
|
|
|
return shuffled.slice(min);
|
|
@@ -149,6 +160,8 @@ export function pwdProduce(minLen, maxLen, struc) {
|
|
|
if (pwdStruc[3] == 1) {
|
|
|
let arr = numbers
|
|
|
let v = randomAlp(arr, passLong);
|
|
|
+ console.log(v)
|
|
|
+
|
|
|
for (let i = 0; i < passLong; i++) {
|
|
|
dis += v[i]
|
|
|
}
|