From 31a72f54ac82130f7bf5a7826a26fab6940e313e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 14 Jul 2024 20:36:05 +0800 Subject: [PATCH] bugfix --- appPublic/dataencoder.py | 11 +++++++++++ appPublic/httpclient.py | 2 ++ appPublic/rc4.py | 11 ++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/appPublic/dataencoder.py b/appPublic/dataencoder.py index 66582fe..5c8b18e 100755 --- a/appPublic/dataencoder.py +++ b/appPublic/dataencoder.py @@ -157,3 +157,14 @@ class DataEncoder: def verify_sign(self, data, sign, peer_pubkey): return self.rsa.check_sign_bdata(peer_pubkey, data, sign) + +def quotedstr(s): + def conv(c): + if c == '"': + return '\\"' + if c == '\n': + return '\\n' + return c + x = [ conv(c) for c in s ] + return ''.join(x) + diff --git a/appPublic/httpclient.py b/appPublic/httpclient.py index 6f9e985..aed9aee 100755 --- a/appPublic/httpclient.py +++ b/appPublic/httpclient.py @@ -1,6 +1,7 @@ import asyncio import aiohttp import re +from appPublic.log import info, debug, warning, error, exception, critical RESPONSE_BIN = 0 RESPONSE_TEXT = 1 @@ -95,6 +96,7 @@ class HttpClient: if resp.status==200: return await self.handleResp(url, resp, response_type, stream_func=stream_func) msg = f'http error({resp.status}, {url=},{params=}, {data=}, {jd=}, {headers=}, {kw=})' + exception(msg) raise HttpError(resp.status, msg) async def get(self,url,**kw): diff --git a/appPublic/rc4.py b/appPublic/rc4.py index 2e34ad0..4752dab 100755 --- a/appPublic/rc4.py +++ b/appPublic/rc4.py @@ -166,19 +166,20 @@ class KeyChain(object): if d is None: return None return d.decode('utf-8') + pwdkey = 'ytguiojbhvhbnkl' -def password(pwdtxt): +def password(pwdtxt, key=pwdkey): rc = RC4() - code = rc.encode(pwdtxt, pwdkey) - t = rc.decode(code, pwdkey) + code = rc.encode(pwdtxt, key) + t = rc.decode(code, key) if (t == pwdtxt): return code else: return None -def unpassword(code): +def unpassword(code, key=pwdkey): rc = RC4() - t = rc.decode(code, pwdkey) + t = rc.decode(code, key) return t """