|
import gradio as gr |
|
import random |
|
import string |
|
|
|
def generate_password(length): |
|
|
|
upper = string.ascii_uppercase |
|
lower = string.ascii_lowercase |
|
digits = string.digits |
|
special = string.punctuation |
|
|
|
|
|
all_characters = upper + lower + digits + special |
|
password = [ |
|
random.choice(upper), |
|
random.choice(lower), |
|
random.choice(digits), |
|
random.choice(special) |
|
] |
|
|
|
|
|
password += random.choices(all_characters, k=length-4) |
|
|
|
|
|
random.shuffle(password) |
|
|
|
|
|
return ''.join(password) |
|
|
|
|
|
interface = gr.Interface( |
|
fn=generate_password, |
|
inputs=gr.Slider(minimum=8, maximum=32, step=1, value=12, label="Password Length"), |
|
outputs="text", |
|
title="Password Generator", |
|
description="Generate a strong, unique password by selecting the desired length." |
|
) |
|
|
|
interface.launch() |
|
|