Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ab1a2c

Browse files
Merge pull request avinashkranjan#1711 from sagnik-p/password-generator-gui
customizable Password generator GUI
2 parents bd5b280 + 2dcfbfd commit 1ab1a2c

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

‎GUI-Password-Generator/generator.py‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import random
2+
import pyperclip
3+
from tkinter import *
4+
from tkinter.ttk import *
5+
6+
def getStrength():
7+
entry.delete(0, END)
8+
length = var1.get()
9+
lower = "abcdefghijklmnopqrstuvwxyz"
10+
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
11+
digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 !@#$%^&*()"
12+
password = ""
13+
14+
# if strength selected is low
15+
if var.get() == 1:
16+
for i in range(0, length):
17+
password = password + random.choice(lower)
18+
return password
19+
20+
# if strength selected is medium
21+
elif var.get() == 0:
22+
for i in range(0, length):
23+
password = password + random.choice(upper)
24+
return password
25+
26+
# if strength selected is strong
27+
elif var.get() == 3:
28+
for i in range(0, length):
29+
password = password + random.choice(digits)
30+
return password
31+
else:
32+
print("Please choose an option")
33+
34+
35+
# Function for generation of password
36+
def generate():
37+
password1 = getStrength()
38+
entry.insert(10, password1)
39+
40+
41+
# Function for copying password to clipboard
42+
def copy():
43+
random_password = entry.get()
44+
pyperclip.copy(random_password)
45+
46+
47+
# create GUI window
48+
root = Tk()
49+
var = IntVar()
50+
var1 = IntVar()
51+
52+
53+
54+
# Title of the GUI window
55+
root.title("Password Generator")
56+
57+
# create label for length of password
58+
c_label = Label(root, text="Length")
59+
c_label.grid(row=0)
60+
copy_button = Button(root, text="Copy", command=copy)
61+
copy_button.grid(row=0, column=2)
62+
generate_button = Button(root, text="Generate", command=generate)
63+
generate_button.grid(row=0, column=3)
64+
65+
radio_low = Radiobutton(root, text="Low", variable=var, value=1)
66+
radio_low.grid(row=1, column=2, sticky='E')
67+
radio_middle = Radiobutton(root, text="Medium", variable=var, value=0)
68+
radio_middle.grid(row=1, column=3, sticky='E')
69+
radio_strong = Radiobutton(root, text="Strong", variable=var, value=3)
70+
radio_strong.grid(row=1, column=4, sticky='E')
71+
combo = Combobox(root, textvariable=var1)
72+
combo['values'] = (8, 9, 10, 11, 12, 13, 14, 15, 16,
73+
17, 18, 19, 20, 21, 22, 23, 24, 25,
74+
26, 27, 28, 29, 30, 31, 32)
75+
combo.current(0)
76+
combo.bind('<<ComboboxSelected>>')
77+
combo.grid(column=1, row=0)
78+
Random_password = Label(root, text="Generated password",padding=5)
79+
Random_password.grid(row=1)
80+
entry = Entry(root)
81+
entry.grid(row=1, column=1)
82+
83+
84+
##run the GUI continuously
85+
root.mainloop()

‎GUI-Password-Generator/readme.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Password Generator tool
2+
3+
This is a GUI app that Generates a random password
4+
5+
Features:
6+
Length can be selected
7+
Strength can be selected
8+
Copy to clipboard button
9+
10+
11+
modules needed: pyperclip
12+
>pip install pyperclip
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyperclip==1.8.2

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /