Mohammed98 commited on
Commit
9ac430b
·
verified ·
1 Parent(s): 94b08e6

upload the code

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import bcrypt
3
+
4
+ def hash_password(password: str) -> str:
5
+ if not password:
6
+ return "❌ Please enter a password"
7
+ # Convert to bytes
8
+ pw_bytes = password.encode("utf-8")
9
+ # Generate salt + hash
10
+ hashed = bcrypt.hashpw(pw_bytes, bcrypt.gensalt(rounds=12))
11
+ return hashed.decode("utf-8")
12
+
13
+ # Gradio Interface
14
+ demo = gr.Interface(
15
+ fn=hash_password,
16
+ inputs=gr.Textbox(type="password", label="Enter your password"),
17
+ outputs=gr.Textbox(label="Generated hash"),
18
+ title="Password Hasher 🔐",
19
+ description="Enter a password and get its bcrypt hash"
20
+ )
21
+
22
+ if __name__ == "__main__":
23
+ demo.launch()