From c8ee2ea8d188dab52aa5c16b72e8dd35befd1c75 Mon Sep 17 00:00:00 2001 From: xaoyaoo Date: Tue, 6 Aug 2024 22:40:19 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=9B=B4=E6=8D=A2=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E6=B3=95=E8=87=AA=E5=8A=A8=E5=90=AF=E7=94=A8?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pywxdump/api/local_server.py | 11 ++++++++--- pywxdump/api/utils.py | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pywxdump/api/local_server.py b/pywxdump/api/local_server.py index 6e9b56b..c152fbb 100644 --- a/pywxdump/api/local_server.py +++ b/pywxdump/api/local_server.py @@ -19,7 +19,7 @@ from flask import Flask, request, render_template, g, Blueprint, send_file, make from pywxdump import get_core_db, all_merge_real_time_db, get_wx_db from pywxdump.api.rjson import ReJson, RqJson from pywxdump.api.utils import get_conf, get_conf_wxids, set_conf, error9999, gen_base64, validate_title, \ - get_conf_local_wxid, ls_loger + get_conf_local_wxid, ls_loger, random_str from pywxdump import get_wx_info, WX_OFFS, batch_decrypt, BiasAddr, merge_db, decrypt_merge, merge_real_time_db from pywxdump.db import DBHandler, download_file, export_csv, export_json @@ -123,7 +123,7 @@ def init_key(): # 显示堆栈信息 ls_loger.error(f"{e}", exc_info=True) db_config = { - "key": "merge_all", + "key": random_str(16), "type": "sqlite", "path": merge_save_path_new } @@ -166,7 +166,12 @@ def init_nokey(): return ReJson(1002, body=f"my_wxid is required: {my_wxid}") key = get_conf(g.caf, my_wxid, "key") - + db_config = { + "key": random_str(16), + "type": "sqlite", + "path": merge_path + } + set_conf(g.caf, my_wxid, "db_config", db_config) set_conf(g.caf, my_wxid, "merge_path", merge_path) set_conf(g.caf, my_wxid, "wx_path", wx_path) set_conf(g.caf, my_wxid, "key", key) diff --git a/pywxdump/api/utils.py b/pywxdump/api/utils.py index 1a61a8f..852aa04 100644 --- a/pywxdump/api/utils.py +++ b/pywxdump/api/utils.py @@ -8,7 +8,9 @@ import base64 import json import os +import random import re +import string import traceback from .rjson import ReJson from functools import wraps @@ -123,3 +125,7 @@ def gen_base64(path): base64_encoded_js = base64.b64encode(js_code).decode('utf-8') return start_str + base64_encoded_js + + +def random_str(num=16): + return ''.join(random.sample(string.ascii_letters + string.digits, num))