This repository has been archived on 2022-05-11. You can view files and clone it, but cannot push or open issues or pull requests.
misc/scripts/matrix-register.py

25 lines
784 B
Python
Executable File

import hmac, hashlib
import sys
def generate_mac(nonce, user, password, admin=False, user_type=None):
mac = hmac.new(
key=b'q8rs93aB%9ZfuaWPe9WE',
digestmod=hashlib.sha1,
)
mac.update(nonce.encode('utf8'))
mac.update(b"\x00")
mac.update(user.encode('utf8'))
mac.update(b"\x00")
mac.update(password.encode('utf8'))
mac.update(b"\x00")
mac.update(b"admin" if admin else b"notadmin")
if user_type:
mac.update(b"\x00")
mac.update(user_type.encode('utf8'))
return mac.hexdigest()
print(generate_mac(sys.argv[1], sys.argv[2], sys.argv[3]))
#print(generate_mac("f80c3965149c3fe151d375c50fa0e45d27d3823e9a28f2d3675a1540092d988460620e2309c1b28e649a5f624176ba990948efe92d2492408f8be71d4596406f", "maya", "mayacutie"))