-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwgtor.py
139 lines (98 loc) · 4.19 KB
/
pwgtor.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import string
from random import *
class PwGtor:
"""
Method to generate password.
@type limit: int or list
@param x: range of the password characters
@type lowerCase: boolean
@param lowerCase: lower case characters in password or not
@type upperCase: boolean
@param upperCase: upper case characters in password or not
@type lowerCase: digits
@param lowerCase: digits in password or not
@type lowerCase: punctuation
@param lowerCase: punctuation characters in password or not
@return: string
"""
def generate(self, limit, lowerCase, upperCase, digits, punctuation):
available = ""
if(lowerCase):
available += string.ascii_lowercase
if(upperCase):
available += string.ascii_uppercase
if(digits):
available += string.digits + string.digits
if(punctuation):
available += string.digits + string.punctuation
if(isinstance(limit,int)):
password = "".join(choice(available) for x in range(limit))
else:
if(len(limit) == 2):
password = "".join(choice(available) for x in range(randint(limit[0], limit[1])))
else:
password = "Wrong limit parameter!"
return password
"""
Method to generate bulk passwords.
@type number: int
@param number: number of passwords, default: 1
@type limit: int or list
@param x: range of the password characters, default: [8, 16]
@type lowerCase: boolean
@param lowerCase: lower case characters in password or not, default: True
@type upperCase: boolean
@param upperCase: upper case characters in password or not, default: True
@type lowerCase: digits
@param lowerCase: digits in password or not, default: True
@type lowerCase: punctuation
@param lowerCase: punctuation characters in password or not, default: True
@return: list
"""
def bulk(self, number = 5, limit = [8, 16], lowerCase = True, upperCase = True, digits = True, punctuation = True):
passwords = []
for x in range(number):
password = self.generate(limit, lowerCase, upperCase, digits, punctuation)
passwords.append(password)
return passwords
"""
Method to generate single password.
@type number: int
@param number: number of passwords, default: 1
@type limit: int or list
@param x: range of the password characters, default: [8, 16]
@type lowerCase: boolean
@param lowerCase: lower case characters in password or not, default: True
@type upperCase: boolean
@param upperCase: upper case characters in password or not, default: True
@type lowerCase: digits
@param lowerCase: digits in password or not, default: True
@type lowerCase: punctuation
@param lowerCase: punctuation characters in password or not, default: True
@return: string
"""
def single(self, limit = [8, 16], lowerCase = True, upperCase = True, digits = True, punctuation = True):
return self.generate(limit, lowerCase, upperCase, digits, punctuation)
"""
Method to generate a file with bulk passwords.
@type number: int
@param number: number of passwords, default: 1
@type limit: int or list
@param x: range of the password characters, default: [8, 16]
@type lowerCase: boolean
@param lowerCase: lower case characters in password or not, default: True
@type upperCase: boolean
@param upperCase: upper case characters in password or not, default: True
@type lowerCase: digits
@param lowerCase: digits in password or not, default: True
@type lowerCase: punctuation
@param lowerCase: punctuation characters in password or not, default: True
@create: file
"""
def file(self, number=5, filePath = "passwords.txt", seperator = "\n", limit=[8, 16], lowerCase=True, upperCase=True, digits=True, punctuation=True):
pf = open(filePath, "w+")
for x in range(number):
password = self.generate(limit, lowerCase, upperCase, digits, punctuation)
pf.write(password + seperator)
pf.close()
return