import gradio as gr def generate_secure_password(full_name, private_word): name = full_name.strip().lower() secret = private_word.strip().lower() if not name or not secret: return "خطأ: يرجى إدخال الاسم والكلمة الخاصة!" first_two = name[:2] last_char = name[-1] combined = first_two + last_char + secret capitalized_part = combined.capitalize() final_password = f"{capitalized_part}_{len(combined)}" return final_password # إنشاء واجهة Gradio with gr.Blocks(title="مُولد كلمات السر الذكي") as demo: gr.Markdown("# 🛡️ نظام توليد كلمات السر الخاص بك") gr.Markdown("أدخل بياناتك للحصول على كلمة سر فريدة بناءً على خوارزميتك الخاصة.") with gr.Row(): name_input = gr.Textbox(label="الاسم الكامل ") secret_input = gr.Textbox(label="كلمتك السرية الخاصة", placeholder="كلمة لا يعرفها غيرك", type="password") output_text = gr.Textbox(label="كلمة السر الناتجة", interactive=False) submit_btn = gr.Button("توليد كلمة السر", variant="primary") # ربط الوظيفة بالزر submit_btn.click( fn=generate_secure_password, inputs=[name_input, secret_input], outputs=output_text ) # تشغيل التطبيق if __name__ == "__main__": demo.launch()