hassan773 commited on
Commit
d536884
·
verified ·
1 Parent(s): 0bf9158

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -12,7 +12,6 @@ VAULT_FILE = "passwords.json"
12
  # --- Encryption Logic ---
13
 
14
  def get_cipher(master_password):
15
- """Derives a cryptographic key from the master password."""
16
  salt = b'nutech_hassan_salt_123'
17
  kdf = PBKDF2HMAC(
18
  algorithm=hashes.SHA256(),
@@ -30,7 +29,6 @@ def process_vault(action, master_pwd, service=None, secret=None):
30
  try:
31
  cipher = get_cipher(master_pwd)
32
 
33
- # Load the vault
34
  if os.path.exists(VAULT_FILE):
35
  with open(VAULT_FILE, "r") as f:
36
  vault = json.load(f)
@@ -62,8 +60,6 @@ def process_vault(action, master_pwd, service=None, secret=None):
62
  custom_css = """
63
  .gradio-container { max-width: 700px; margin: auto; }
64
  .header-text { text-align: center; margin-bottom: 20px; }
65
- .header-text h1 { margin: 0; }
66
- .header-text span { font-size: 0.8em; color: gray; }
67
  """
68
 
69
  with gr.Blocks() as demo:
@@ -93,10 +89,19 @@ with gr.Blocks() as demo:
93
 
94
  status_output = gr.Textbox(label="Vault Status", interactive=False)
95
 
96
- # Event Handlers
97
- save_btn.click(process_vault, ["Save", master_key, svc, pwd], status_output)
98
- get_btn.click(process_vault, ["Retrieve", master_key, search_svc], status_output)
 
 
 
 
 
 
 
 
 
 
99
 
100
  if __name__ == "__main__":
101
- # Moved CSS to launch for Gradio 6
102
  demo.launch(css=custom_css)
 
12
  # --- Encryption Logic ---
13
 
14
  def get_cipher(master_password):
 
15
  salt = b'nutech_hassan_salt_123'
16
  kdf = PBKDF2HMAC(
17
  algorithm=hashes.SHA256(),
 
29
  try:
30
  cipher = get_cipher(master_pwd)
31
 
 
32
  if os.path.exists(VAULT_FILE):
33
  with open(VAULT_FILE, "r") as f:
34
  vault = json.load(f)
 
60
  custom_css = """
61
  .gradio-container { max-width: 700px; margin: auto; }
62
  .header-text { text-align: center; margin-bottom: 20px; }
 
 
63
  """
64
 
65
  with gr.Blocks() as demo:
 
89
 
90
  status_output = gr.Textbox(label="Vault Status", interactive=False)
91
 
92
+ # --- FIXED EVENT HANDLERS ---
93
+ # We use lambda to pass the "Save" and "Retrieve" strings correctly
94
+ save_btn.click(
95
+ fn=lambda m, s, p: process_vault("Save", m, s, p),
96
+ inputs=[master_key, svc, pwd],
97
+ outputs=status_output
98
+ )
99
+
100
+ get_btn.click(
101
+ fn=lambda m, s: process_vault("Retrieve", m, s),
102
+ inputs=[master_key, search_svc],
103
+ outputs=status_output
104
+ )
105
 
106
  if __name__ == "__main__":
 
107
  demo.launch(css=custom_css)