-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_password.py
40 lines (34 loc) · 1.02 KB
/
random_password.py
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
38
39
40
#Basic Auto password generator
#Just add to directory, and type "python3 random_password.py" and get a random string of uppercase, lowercase, numbers and
#special characters, 8-20 characters long.
import random
length = random.randint(8,20)
pword = 0
caps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #26
lower = "abcdefghijklmnopqrstuvwxyz" #26
number = "12345678901234567890123456" #26
special = "!@#$%^&*()?/_=-+.`~{}[];:," #26
new_pword = ""
def getChar(string, num):
return string[num]
def getList(num, rand):
match num:
case 1:
x = getChar(caps, rand)
return x
case 2:
x = getChar(lower, rand)
return x
case 3:
x = getChar(number, rand)
return x
case 4:
x = getChar(special, rand)
return x
while (pword <= length):
rand_char = random.randint(0,25)
rand_list = random.randint(1,4)
newPword = getList(rand_list, rand_char)
new_pword+=newPword
pword+=1
print("The new password is:", new_pword)