-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrandom_password_creator.py
56 lines (35 loc) · 1.17 KB
/
random_password_creator.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
import string
import random
class Password:
def __init__(self,charset,length):
self.charset = charset
self.length =length
self.char_array = []
self.password = []
def set_the_charset(self):
if('l' in self.charset):
self.char_array.append(string.ascii_lowercase)
if ('u' in self.charset):
self.char_array.append(string.ascii_uppercase)
if ('d' in self.charset):
self.char_array.append(string.digits)
if ('s' in self.charset):
self.char_array.append(string.punctuation)
def get_char_array(self):
return self.char_array
def generate_password(self):
#print(self.char_array)
for i in range(self.length):
outer_index = random.randrange(0,len(self.char_array))
inner_index = random.randrange(0,len(self.char_array[outer_index]))
self.password.append(self.char_array[outer_index][inner_index])
def get_password(self):
return ''.join(self.password)
# l - lowercase
# u -uppercase
# d - digit
# s- special character
#ldu
#ls
#l
#u