|
|
@ -580,7 +580,7 @@ def enCrypt(key, strings): |
|
|
|
# 加密字符串 |
|
|
|
# 加密字符串 |
|
|
|
try: |
|
|
|
try: |
|
|
|
import base64 |
|
|
|
import base64 |
|
|
|
_key = md5(key).encode('utf-8') |
|
|
|
_key = key.encode('utf-8') |
|
|
|
_key = base64.urlsafe_b64encode(_key) |
|
|
|
_key = base64.urlsafe_b64encode(_key) |
|
|
|
|
|
|
|
|
|
|
|
if type(strings) != bytes: |
|
|
|
if type(strings) != bytes: |
|
|
@ -596,6 +596,44 @@ def enCrypt(key, strings): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deCrypt(key, strings): |
|
|
|
def deCrypt(key, strings): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 解密字符串 |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
import base64 |
|
|
|
|
|
|
|
_key = key.encode('utf-8') |
|
|
|
|
|
|
|
_key = base64.urlsafe_b64encode(_key) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if type(strings) != bytes: |
|
|
|
|
|
|
|
strings = strings.encode('utf-8') |
|
|
|
|
|
|
|
from cryptography.fernet import Fernet |
|
|
|
|
|
|
|
f = Fernet(_key) |
|
|
|
|
|
|
|
result = f.decrypt(strings).decode('utf-8') |
|
|
|
|
|
|
|
return result |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
print(getTracebackInfo()) |
|
|
|
|
|
|
|
return strings |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def enDoubleCrypt(key, strings): |
|
|
|
|
|
|
|
# 加密字符串 |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
import base64 |
|
|
|
|
|
|
|
_key = md5(key).encode('utf-8') |
|
|
|
|
|
|
|
_key = base64.urlsafe_b64encode(_key) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if type(strings) != bytes: |
|
|
|
|
|
|
|
strings = strings.encode('utf-8') |
|
|
|
|
|
|
|
import cryptography |
|
|
|
|
|
|
|
from cryptography.fernet import Fernet |
|
|
|
|
|
|
|
f = Fernet(_key) |
|
|
|
|
|
|
|
result = f.encrypt(strings) |
|
|
|
|
|
|
|
return result.decode('utf-8') |
|
|
|
|
|
|
|
except: |
|
|
|
|
|
|
|
print(getTracebackInfo()) |
|
|
|
|
|
|
|
return strings |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deDoubleCrypt(key, strings): |
|
|
|
# 解密字符串 |
|
|
|
# 解密字符串 |
|
|
|
try: |
|
|
|
try: |
|
|
|
import base64 |
|
|
|
import base64 |
|
|
|