-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword.py
27 lines (24 loc) · 1.01 KB
/
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
import string
from random import choice, randint, shuffle
from pyperclip import copy
class Password:
def __init__(self, password_field):
self.letters = string.ascii_letters
self.numbers = string.digits
self.symbols = ["@", "!", "$", "#", "&", "*", "+",]
self.num_letters = randint(8, 10)
self.num_numbers = randint(2, 4)
self.num_symbols = randint(2, 4)
self.password = ""
self.password_field = password_field
def generate_password(self)-> str:
"""_Generate a password that includes letters, numbers and symbols_
"""
self.password_field.delete(0, 'end')
password_1 = [choice(self.letters) for _ in range(self.num_letters)]
password_1 += [choice(self.numbers) for _ in range(self.num_numbers)]
password_1 += [choice(self.symbols) for _ in range(self.num_symbols)]
shuffle(password_1)
self.password= "".join(password_1)
self.password_field.insert(0, self.password)
copy(self.password)