Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "users": [
- {
- "password": "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918",
- "username": "Admin"
- }
- ]
- }
- json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- with open('userProfiles.json', 'r+') as f: #Open up the json file for reading/writing.
- data = f.read()
- print(data) # Debug message to check if f.read actually contains anything...
- currentProfiles = json.loads(data) # Load the json into a useable list.
- print(currentProfiles) # Debug Message: So I can check if the list loads properly
- username = input("Enter username: ")
- password = hashlib.sha256((input("Enter Password: ")).encode('utf-8')).hexdigest() # Create an sha256 hash to be used later to authenticate users.
- newUser = json.dumps({'users':[{'username':username, 'password':password}]}, sort_keys=True, indent=4)
- f.write(newUser)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement