0% found this document useful (0 votes)
3 views5 pages

Python Password Generator Tool

The document presents a Python project for a 'Password Generator' using the customtkinter library. It includes functions to assess password strength, generate passwords based on user-selected criteria, and copy the generated password to the clipboard. The GUI allows users to specify password length and character types, and provides visual feedback on password strength.

Uploaded by

prachiraj9149
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Python Password Generator Tool

The document presents a Python project for a 'Password Generator' using the customtkinter library. It includes functions to assess password strength, generate passwords based on user-selected criteria, and copy the generated password to the clipboard. The GUI allows users to specify password length and character types, and provides visual feedback on password strength.

Uploaded by

prachiraj9149
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON PROJECT

PROJECT NAME:- “PASSWORD GENERATOR”


CODE:-

#Program to make a password generator.


import customtkinter as ctk
import string
import secrets

# -------------------------
# Password Strength Logic
# -------------------------
def assess_strength(password):
length = len(password)
categories = 0

if any([Link]() for c in password):


categories += 1
if any([Link]() for c in password):
categories += 1
if any([Link]() for c in password):
categories += 1
if any(c in "!@#$%^&*()-_=+[]{}|;:,.<>?" for c in password):
categories += 1

score = length + (categories * 2)

if score < 10:


return "Weak", "#ff4d4d"
elif score < 16:
return "Medium", "#ffcc00"
else:
return "Strong", "#33cc33"

# -------------------------
# Password Generator
# -------------------------
def generate_password():
length = int(length_slider.get())

pools = []
if upper_switch.get():
[Link](string.ascii_uppercase)
if lower_switch.get():
[Link](string.ascii_lowercase)
if digits_switch.get():
[Link]([Link])
if special_switch.get():
[Link]("!@#$%^&*()-_=+[]{}|;:,.<>?")
if not pools:
output_label.configure(text="Select at least one option")
return

all_chars = "".join(pools)

password = [[Link](pool) for pool in pools]

for _ in range(length - len(password)):


[Link]([Link](all_chars))

[Link]().shuffle(password)
final_pw = "".join(password)

output_label.configure(text=final_pw)

# Strength meter update


strength, color = assess_strength(final_pw)
strength_label.configure(text=f"Strength: {strength}", text_color=color)

# -------------------------
# Copy to Clipboard
# -------------------------
def copy_password():
pw = output_label.cget("text")
app.clipboard_clear()
app.clipboard_append(pw)
copy_btn.configure(text="Copied!")
[Link](1500, lambda: copy_btn.configure(text="Copy"))

# -------------------------
# GUI Setup
# -------------------------
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")

app = [Link]()
[Link]("Modern Password Generator")
[Link]("450x550")

title = [Link](app, text="�Modern Password Generator", font=("Arial", 22, "bold"))


[Link](pady=15)

# Length Slider
length_frame = [Link](app)
length_frame.pack(pady=15, fill="x", padx=20)

[Link](length_frame, text="Password Length:", font=("Arial", 14)).pack(pady=5)


length_slider = [Link](length_frame, from_=6, to=30, number_of_steps=24)
length_slider.set(12)
length_slider.pack(pady=5)
# Switches for options
options_frame = [Link](app)
options_frame.pack(pady=10, fill="x", padx=20)

upper_switch = [Link](options_frame, text="Uppercase (A-Z)", switch_width=50)


upper_switch.select()
upper_switch.pack(anchor="w", pady=4)

lower_switch = [Link](options_frame, text="Lowercase (a-z)", switch_width=50)


lower_switch.select()
lower_switch.pack(anchor="w", pady=4)

digits_switch = [Link](options_frame, text="Digits (0-9)", switch_width=50)


digits_switch.select()
digits_switch.pack(anchor="w", pady=4)

special_switch = [Link](options_frame, text="Special Characters", switch_width=50)


special_switch.select()
special_switch.pack(anchor="w", pady=4)

# Generate Button
generate_btn = [Link](app, text="Generate Password", command=generate_password)
generate_btn.pack(pady=20)

# Output Box
output_label = [Link](app, text="", font=("Consolas", 18, "bold"))
output_label.pack(pady=10)

# Strength Meter
strength_label = [Link](app, text="Strength: ", font=("Arial", 14, "bold"))
strength_label.pack(pady=5)

# Copy Button
copy_btn = [Link](app, text="Copy", width=120, command=copy_password)
copy_btn.pack(pady=15)

[Link]()
OUTPUT:-

You might also like