From 22b65ca06dd1a39fa0e1530662e068b453d1440c Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 30 Jun 2020 08:03:36 +0000 Subject: [PATCH] fix crypto import --- .../agents/management/commands/helpers.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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")