From 5b03e4add421bda691466b70a8d8c4c15cd8de1a Mon Sep 17 00:00:00 2001 From: chenzuoqing Date: Tue, 21 Dec 2021 15:52:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=86=E7=A0=81=E5=8A=A0?= =?UTF-8?q?=E5=AF=86=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings/common.py | 3 +++ src/common/crypto.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/settings/common.py b/settings/common.py index 13d4d04..02240ad 100644 --- a/settings/common.py +++ b/settings/common.py @@ -11,6 +11,9 @@ CONFIG: dict = load_yaml(CONFIG_FILE, raise_exception=True, default={}) VERSION = "v1" INSTANCE = "9e5da0b3-565f-11ec-b095-18c04d9eb245" +# 请注意修改,涉及加密 +SECRET_KEY = "_%77bE8b62Z!11eCbdF4/18C04@d9b24" + # API static token 允许请求的静态token X_TOKEN_SET = ( "51ab21fa323a11eca1af000c2993d583", # diff --git a/src/common/crypto.py b/src/common/crypto.py index 23f416b..cab4895 100644 --- a/src/common/crypto.py +++ b/src/common/crypto.py @@ -4,6 +4,8 @@ from os import urandom from hashlib import md5 from Crypto.Cipher import AES +from settings.common import SECRET_KEY + """pip3 install pycryptodome""" @@ -92,6 +94,12 @@ class AESCipher: return out_file.getvalue() +def quick_crypto(content): + cipher = AESCipher(content=content, password=SECRET_KEY) + result = cipher.encrypt() + return result.decode() + + if __name__ == '__main__': print("++++++++++++++++++++++++++++++++++++++++++") aes = AESCipher("hello world2223", '111111')