-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_credentials.py
More file actions
56 lines (44 loc) · 1.36 KB
/
change_credentials.py
File metadata and controls
56 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
"""
Simple script to manage file manager credentials
Run this to change your username/password
"""
import json
import bcrypt
import os
USERS_FILE = "users.json"
def load_users():
if os.path.exists(USERS_FILE):
with open(USERS_FILE, 'r') as f:
return json.load(f)
return {}
def save_users(users):
with open(USERS_FILE, 'w') as f:
json.dump(users, f, indent=2)
def change_credentials():
print("=" * 50)
print("File Manager - Credential Manager")
print("=" * 50)
username = input("\nEnter username: ").strip()
if not username:
print("❌ Username cannot be empty")
return
password = input("Enter password: ").strip()
if not password:
print("❌ Password cannot be empty")
return
confirm = input("Confirm password: ").strip()
if password != confirm:
print("❌ Passwords don't match")
return
# Hash the password
hashed = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
# Save to file
users = {username: hashed.decode('utf-8')}
save_users(users)
print(f"\n✅ Credentials updated successfully!")
print(f"Username: {username}")
print(f"Password: {'*' * len(password)}")
print(f"\nCredentials saved to {USERS_FILE}")
if __name__ == "__main__":
change_credentials()