This commit is contained in:
yumoqing 2024-07-14 20:36:05 +08:00
parent e42f61c8a2
commit 31a72f54ac
3 changed files with 19 additions and 5 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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
"""