Skip to content

Commit b903b59

Browse files
committed
🚸 Use password obfuscation
thanks to @\thelastfreedom
1 parent aadf3d0 commit b903b59

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ from comwatt.client import ComwattClient
3232
client = ComwattClient()
3333

3434
# Authenticate the user
35-
# Password should be encrypted password,
36-
# I don't know exactly what the encryption is for the moment,
37-
# so you will need to encrypt it from their webapp
3835
client.authenticate('username', 'password')
3936

4037
# Get information about the authenticated user

src/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22
import json
3+
import hashlib
34

45
class ComwattClient:
56
"""
@@ -17,15 +18,13 @@ def __init__(self):
1718
self.base_url = 'https://energy.comwatt.com/api'
1819
self.session = requests.Session()
1920

20-
# Password should be encrypted password, I don't know exactly what the encryption is for the
21-
# moment, so you will need to encrypt it from their webapp
2221
def authenticate(self, username, password):
2322
"""
2423
Authenticates a user with the provided username and password.
2524
2625
Args:
2726
username (str): The username of the user.
28-
password (str): The password of the user (encrypted).
27+
password (str): The password of the user.
2928
3029
Returns:
3130
None
@@ -36,7 +35,8 @@ def authenticate(self, username, password):
3635
"""
3736

3837
url = f'{self.base_url}/v1/authent'
39-
data = {'username': username, 'password': password}
38+
encoded_password = hashlib.sha256(f'jbjaonfusor_{password}_4acuttbuik9'.encode()).hexdigest()
39+
data = {'username': username, 'password': encoded_password}
4040

4141
response = self.session.post(url, json=data)
4242

0 commit comments

Comments
 (0)