File tree Expand file tree Collapse file tree 2 files changed +8
-21
lines changed
magic_dash/templates/magic-dash-pro Expand file tree Collapse file tree 2 files changed +8
-21
lines changed Original file line number Diff line number Diff line change 1313from configs import BaseConfig
1414
1515
16- def load_rsa_public_key ():
17- """加载RSA公钥文件内容
16+ # 模块级别加载RSA公钥和私钥(只加载一次)
17+ with open (BaseConfig .rsa_public_key_path , "r" , encoding = "utf-8" ) as f :
18+ rsa_public_key = f .read ()
1819
19- 从项目根目录读取public_key.pem文件
20-
21- Returns:
22- str: 公钥PEM格式字符串
23- None: 加载失败时返回None
24- """
25-
26- with open (BaseConfig .rsa_public_key_path , "r" , encoding = "utf-8" ) as f :
27- return f .read ()
20+ with open (BaseConfig .rsa_private_key_path , "rb" ) as f :
21+ private_key = serialization .load_pem_private_key (
22+ f .read (), password = None , backend = default_backend ()
23+ )
2824
2925
3026def decrypt_password (encrypted_base64 : str ) -> str :
@@ -49,12 +45,6 @@ def decrypt_password(encrypted_base64: str) -> str:
4945 return None
5046
5147 try :
52- # 读取私钥
53- with open (BaseConfig .rsa_private_key_path , "rb" ) as f :
54- private_key = serialization .load_pem_private_key (
55- f .read (), password = None , backend = default_backend ()
56- )
57-
5848 # Base64解码加密数据
5949 encrypted_data = base64 .b64decode (encrypted_base64 )
6050
Original file line number Diff line number Diff line change 44from feffery_dash_utils .style_utils import style
55
66from configs import BaseConfig , LayoutConfig
7- from utils .crypto_utils import load_rsa_public_key
7+ from utils .crypto_utils import rsa_public_key
88
99# 令绑定的回调函数子模块生效
1010import callbacks .login_c # noqa: F401
1313def render ():
1414 """渲染用户登录页面"""
1515
16- # 加载RSA公钥
17- rsa_public_key = load_rsa_public_key ()
18-
1916 return fac .AntdRow (
2017 [
2118 # 左侧半边
You can’t perform that action at this time.
0 commit comments