Skip to content

Commit 8f10ed3

Browse files
committed
git commit -m "Add password generator script, readme, and requirements
This commit adds a Python script for generating strong passwords using the tkinter GUI library, as well as a readme file with usage instructions and dependencies, and a requirements file specifying the required packages and versions. The password generator script includes the ability to set the length of the password, validate user input, and copy the generated password to the clipboard.
1 parent 61bd2cb commit 8f10ed3

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import tkinter as tk
2+
import random
3+
import string
4+
import pyperclip
5+
6+
# Define the main function for generating the password
7+
def generate_password():
8+
password_length = length_entry.get()
9+
if password_length.isdigit() and int(password_length) > 0:
10+
password = ''.join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=int(password_length)))
11+
password_entry.delete(0, tk.END)
12+
password_entry.insert(0, password)
13+
else:
14+
password_entry.delete(0, tk.END)
15+
password_entry.insert(0, "Invalid password length")
16+
17+
# Define the function for copying the password to the clipboard
18+
def copy_password():
19+
password = password_entry.get()
20+
pyperclip.copy(password)
21+
22+
# Create the main window
23+
root = tk.Tk()
24+
root.title("Password Generator")
25+
26+
# Create the password length label and entry widget
27+
length_label = tk.Label(root, text="Password Length:")
28+
length_label.pack(pady=10)
29+
length_entry = tk.Entry(root, width=5)
30+
length_entry.pack()
31+
32+
# Create the "Generate Password" button
33+
generate_button = tk.Button(root, text="Generate Password", command=generate_password)
34+
generate_button.pack(pady=10)
35+
36+
# Create the password entry widget
37+
password_label = tk.Label(root, text="Generated Password:")
38+
password_label.pack()
39+
password_entry = tk.Entry(root, width=30)
40+
password_entry.pack(pady=10)
41+
42+
# Create the "Copy Password" button
43+
copy_button = tk.Button(root, text="Copy Password", command=copy_password)
44+
copy_button.pack(pady=10)
45+
46+
# Set the focus on the length entry widget
47+
length_entry.focus()
48+
49+
# Run the main loop
50+
root.mainloop()

GUI/Password Generator/readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Password Generator
2+
3+
This is a simple password generator script written in Python using the tkinter GUI library. The script allows the user to specify the length of the password and generates a random password of that length using a combination of uppercase and lowercase letters, digits, and punctuation.
4+
5+
## Usage:
6+
1. Install the required dependencies by running `pip install -r requirements.txt`.
7+
2. Run the script by executing the `password_generator.py` file.
8+
3. Enter a positive integer value for the desired length of the password.
9+
4. Click the "Generate Password" button to generate a new password.
10+
5. Click the "Copy Password" button to copy the generated password to the clipboard.
11+
12+
## Dependencies:
13+
- Python 3.6 or later
14+
- tkinter 8.6 or later
15+
- pyperclip 1.8.2 or later
16+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Required dependencies for the Password Generator script
2+
python_version >= 3.6
3+
tkinter >= 8.6
4+
pyperclip >= 1.8.2

0 commit comments

Comments
 (0)