-
Notifications
You must be signed in to change notification settings - Fork 0
/
PypassGen.py
58 lines (49 loc) · 1.43 KB
/
PypassGen.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import random
import pyperclip
symbol = 0
lower = 0
upper = 0
number = 0
count = 0
password = []
length = input("Hey, Welcome. Just say me how many characters do you want in your password? (default 128)\n")
length = 128 if length is '' else int(length)
#randomly select ascii character classes and individual characters
while count < length:
rand = random.randint (0,3)
if rand == 0:
lower += 1
b = int(random.randint (97,123))
password.append(b)
elif rand == 1:
upper += 1
b = random.randint (65,91)
password.append(b)
elif rand == 2:
number += 1
b = random.randint (48,58)
password.append(b)
elif rand == 3:
r = random.randint(0,2)
symbol += 1
if r == 0:
b = random.randint (33,48)
password.append(b)
elif r == 1:
b = random.randint (91,97)
password.append(b)
elif r == 2:
b = random.randint (123,126)
password.append(b)
count += 1
#convert ascii code to characters
word = "".join([chr(c) for c in password])
#copy pass to clipboard
pyperclip.copy(word)
#print the result
print ("Random password of length %s is: \n" % length)
print('******')
print(word)
print('******')
print ("\nIt contains",lower,"lowercase,",upper,"uppercase,",number,"numbers and",symbol,"symbol characters")
input('Password copied to clipboard, push a button to exit...')