Skip to content

Commit b3d12fd

Browse files
committed
refactor: fmt code
1 parent 05dbc47 commit b3d12fd

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

src/wechat_decrypt_tool/key_service.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ def get_db_key_workflow():
208208

209209
def get_wechat_internal_global_config(wx_dir: Path, file_name1) -> bytes:
210210
"""
211-
获取 Blob 1: 微信内部的 global_config 文件
212-
路径逻辑: account_dir (wxid_xxx) -> parent (xwechat_files) -> all_users -> config -> global_config
211+
读微信目录下的主配置文件
213212
"""
214213
xwechat_files_root = wx_dir.parent
215214

@@ -253,7 +252,6 @@ def get_wechat_internal_global_config(wx_dir: Path, file_name1) -> bytes:
253252

254253

255254
async def fetch_and_save_remote_keys(account: Optional[str] = None) -> Dict[str, Any]:
256-
# 1. 确定账号目录和 WXID
257255
account_dir = _resolve_account_dir(account)
258256
wx_id_dir = _resolve_account_wxid_dir(account_dir)
259257
wxid = wx_id_dir.name
@@ -272,11 +270,8 @@ async def fetch_and_save_remote_keys(account: Optional[str] = None) -> Dict[str,
272270
except Exception as e:
273271
raise RuntimeError(f"读取微信内部文件失败: {e}")
274272

275-
# Blob 3: 空 (联系人)
276273
blob3_bytes = b""
277274

278-
279-
# 3. 构造请求
280275
headers = {
281276
"Accept": "text/x-component",
282277
"Next-Action": NEXT_ACTION_ID,
@@ -338,17 +333,15 @@ async def fetch_and_save_remote_keys(account: Optional[str] = None) -> Dict[str,
338333
xor_raw = str(result_data["xor_key"])
339334
aes_val = str(result_data["aes_key"])
340335

341-
# 转换 XOR Key (服务器返回的是十进制字符串 "178")
342336
try:
343337
if xor_raw.startswith("0x"):
344338
xor_int = int(xor_raw, 16)
345339
else:
346340
xor_int = int(xor_raw)
347-
xor_hex_str = f"0x{xor_int:02X}" # 格式化为 0xB2
341+
xor_hex_str = f"0x{xor_int:02X}"
348342
except:
349-
xor_hex_str = xor_raw # 转换失败则原样保留
343+
xor_hex_str = xor_raw
350344

351-
# 保存到数据库/Store
352345
upsert_account_keys_in_store(
353346
account=wxid,
354347
image_xor_key=xor_hex_str,

src/wechat_decrypt_tool/routers/keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async def get_image_key(account: Optional[str] = None):
9494
通过模拟 Next.js Server Action 协议,利用本地微信配置文件换取 AES/XOR 密钥。
9595
9696
1. 读取 [wx_dir]/all_users/config/global_config (Blob 1)
97-
2. 计算 本地 global_config (JSON) 的 SHA3-224 (Blob 2)
97+
2. 读 同上目录下的global_config.crc
9898
3. 构造 Multipart 包发送至远程服务器
9999
4. 解析返回流,自动存入本地数据库
100100
"""

0 commit comments

Comments
 (0)