Skip to content

Commit

Permalink
Revert "Implement native MD5 authentication"
Browse files Browse the repository at this point in the history
This reverts commit dcf1767.

Undid ALL work on #20 in main branch
  • Loading branch information
thelabcat committed Nov 26, 2024
1 parent 7c622c9 commit 7e970a9
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions src/rumchat_actor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,9 @@ def get_safe_filename(clip_save_path, filename, extension = static.Clip.save_ext
safe_filename = filename + f"({increment})"
return safe_filename

def calc_password_hashes(password, salts):
"""Hash a password given the salts using custom MD5 implementation"""
md5 = MD5Ex()
stretched1 = md5.hash_stretch(password, salts[0], 128)
stretched2 = md5.hash_stretch(password, salts[2], 128)
final_hash1 = md5.hash(stretched1 + salts[1])
return [final_hash1, stretched2, salts[1]]

class MD5Ex:
def __init__(self):
self.hex = list("0123456789abcdef")

def hash(self, message: str) -> str:
if isinstance(message, str):
message = message.encode('utf-8')
return hashlib.md5(message).hexdigest()

def hash_stretch(self, password: str, salt: str, iterations: int = 1024) -> str:
message = (salt + password).encode('utf-8')
current = self.hash(message)
for _ in range(iterations):
current = self.hash(current + password)
return current
# def calc_password_hashes(password, salts):
# """Hash a password given the salts"""
# with open(pjoin(Path(__file__).parent, pjoin("dom_scripts", "md5Ex.js")), 'r') as f:
# js = f.read()
#
# return eval_js(js)(password, salts)

0 comments on commit 7e970a9

Please sign in to comment.