forked from this8/password-generators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sec
37 lines (32 loc) · 934 Bytes
/
sec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
clear()
clc()
// Define character set
lowCase = "abcdefghijklmnopqrstuvxyz";
upCase = "ABCDEFGHIJKLMNOPQRSTUVXYZ";
Numbers = "0123456789";
SpecialChar = "£$&()*+[]@#^-_!?";
charCategories = 4;
// Define password length
passLength = 8;
// Initialize password
password="";
// FOR loop
for i=1:passLength
chooseCharGroup = round(abs(rand()*(charCategories-1)));
select chooseCharGroup
case 0
index = round(abs(rand()*(length(lowCase)-1)));
password=password + part(lowCase,index+1);
case 1
index = round(abs(rand()*(length(upCase)-1)));
password=password + part(upCase,index+1);
case 2
index = round(abs(rand()*(length(Numbers)-1)));
password=password + part(Numbers,index+1);
case 3
index = round(abs(rand()*(length(SpecialChar)-1)));
password = password + part(SpecialChar,index+1);
end
end
// Display password in console
disp(password)