diff --git a/api/tacticalrmm/agents/management/commands/helpers.py b/api/tacticalrmm/agents/management/commands/helpers.py index 6416de19..9b3bc9ed 100644 --- a/api/tacticalrmm/agents/management/commands/helpers.py +++ b/api/tacticalrmm/agents/management/commands/helpers.py @@ -1,15 +1,18 @@ import time from base64 import b64encode -from Cryptodome.Cipher import AES -from Cryptodome.Random import get_random_bytes +from Crypto.Cipher import AES +from Crypto.Random import get_random_bytes + def get_auth_token(user, key): key = bytes.fromhex(key) key1 = key[0:32] - msg = '{{"userid":"{}", "domainid":"{}", "time":{}}}'.format(f"user//{user}", "", int(time.time())) + msg = '{{"userid":"{}", "domainid":"{}", "time":{}}}'.format( + f"user//{user}", "", int(time.time()) + ) iv = get_random_bytes(12) a = AES.new(key1, AES.MODE_GCM, iv) - msg, tag = a.encrypt_and_digest(bytes(msg, 'utf-8')) + msg, tag = a.encrypt_and_digest(bytes(msg, "utf-8")) - return b64encode(iv + tag + msg, altchars=b"@$").decode("utf-8") \ No newline at end of file + return b64encode(iv + tag + msg, altchars=b"@$").decode("utf-8")