-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmalfad.js
23 lines (22 loc) · 997 Bytes
/
malfad.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const password_generator = ( len ) => {
const length = (len) ? (len) : (10);
const string = "qwertyuiopasdfghjklzxcvbnm"; //to upper
const numeric = '1234567890';
const punctuation = '!@#$%^&*()_+~`|}{[]\:;?><,./-=';
let password = "";
let character = "";
while( password.length < length ) {
entity1 = Math.ceil(string.length * Math.random() * Math.random());
entity2 = Math.ceil(numeric.length * Math.random() * Math.random());
entity3 = Math.ceil(punctuation.length * Math.random() * Math.random());
hold = string.charAt( entity1 );
hold = (password.length%2==0) ? (hold.toUpperCase()) : (hold);
character += hold;
character += numeric.charAt( entity2 );
character += punctuation.charAt( entity3 );
password = character;
}
password = password.split('').sort(function(){return 0.5 - Math.random()}).join('');
return password.substr(0,length);
}
console.log( password_generator() );