|
@@ -1,9 +1,11 @@
|
|
|
+import base64
|
|
|
import logging
|
|
|
import time
|
|
|
|
|
|
import requests
|
|
|
|
|
|
from Ansjer.config import BASE_DIR
|
|
|
+from Controller.CheckUserData import RandomStr
|
|
|
from Model.models import *
|
|
|
import json
|
|
|
from django.db.models import Q
|
|
@@ -248,6 +250,44 @@ class ModelService:
|
|
|
file.flush()
|
|
|
file.close()
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ # 加密
|
|
|
+ def encrypt_pwd(userPwd):
|
|
|
+ for i in range(1, 4):
|
|
|
+ if i == 1:
|
|
|
+ userPwd = RandomStr(3, False) + userPwd + RandomStr(3, False)
|
|
|
+ userPwd = base64.b64encode(str(userPwd).encode("utf-8")).decode('utf8')
|
|
|
+ if i == 2:
|
|
|
+ userPwd = RandomStr(2, False) + str(userPwd) + RandomStr(2, False)
|
|
|
+ userPwd = base64.b64encode(str(userPwd).encode("utf-8")).decode('utf8')
|
|
|
+ if i == 3:
|
|
|
+ userPwd = RandomStr(1, False) + str(userPwd) + RandomStr(1, False)
|
|
|
+ userPwd = base64.b64encode(str(userPwd).encode("utf-8")).decode('utf8')
|
|
|
+ return userPwd
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ # 解密
|
|
|
+ def decode_pwd(password):
|
|
|
+ for i in range(1, 4):
|
|
|
+ if i == 1:
|
|
|
+ # 第一次先解密
|
|
|
+ password = base64.b64decode(password)
|
|
|
+ password = password.decode('utf-8')
|
|
|
+ # 截去第一位,最后一位
|
|
|
+ password = password[1:-1]
|
|
|
+ if i == 2:
|
|
|
+ # 第2次先解密
|
|
|
+ password = base64.b64decode(password)
|
|
|
+ password = password.decode('utf-8')
|
|
|
+ # 去前2位,后2位
|
|
|
+ password = password[2:-2]
|
|
|
+ if i == 3:
|
|
|
+ # 第3次先解密
|
|
|
+ password = base64.b64decode(password)
|
|
|
+ password = password.decode('utf-8')
|
|
|
+ # 去前3位,后3位
|
|
|
+ password = password[3:-3]
|
|
|
+ return password
|
|
|
|
|
|
def notify_alexa_delete(userID, UID):
|
|
|
url = 'https://www.zositech.xyz/deviceStatus/delete'
|