|
100鱼币
准备写一个登录QQ邮箱的小程序,腾讯对登录密码的加密算法是用js实现的,本来想用pyv8直接在python中执行js算出密码,奈何用pip装了几次都不成功,遇到各种问题,于是决定直接用python重写,就遇到了下面的问题,困扰了我一天一夜,觉得自己已经掉进思维的陷阱了,头已经大的不行了,特来求助.
先看代码:- s = '0000000096c73e97'
- s1 = '\x00\x00\x00\x00\x96\xc7\x3e\x97'
- lst = []
- i = 0
- while i < len(s):
- lst.append('\\x' + s[i:i+2])
- i += 2
- s2 = ''.join(lst)
- print(s1)
- print(s2)
- print(s1 == s2)
复制代码
s是一个16进制的字符串(从qq号算出来的),现在要每两个字符拿出来和'\x'拼接,预期效果是s1那样,我的python版本是3.5 |
最佳答案
查看完整内容
楼主真是找对人了
看我的代码
def hextokeyword(string):
p=re.compile(".{2}")
split = p.findall(string)
words=bytes()
for x in split:
words = words + struct.pack("B",int(x,16))
words = str(words,"utf-8")
return words
s= "E4B881"
s=hextokeyword(s)
print(s)
结果是 丁
如何把 "丁"转为 "E4B881"呢
import binascii ,re
def ke ...
|