本文来源吾爱破解论坛
分析在前辈的帖子里https://www.52pojie.cn/thread-873265-1-1.html,我用python解了一下,需安装pycrypto库
[Python] 纯文本查看 复制代码
#!/usr/bin/python #-*- coding:utf-8-*- from Crypto.Cipher import AES #from binascii import b2a_hex,a2b_hex import base64,binascii,re,hashlib class AESCBC: def __init__(self, key): self.key = key self.mode = AES.MODE_CBC self.bs = 16 # block size self.PADDING = lambda s: s + (self.bs - len(s) % self.bs) * chr(self.bs - len(s) % self.bs) def encrypt(self, text): generator = AES.new(self.key, self.mode,self.key) try: crypt = generator.encrypt(self.PADDING(text)) crypted_str = base64.b64encode(crypt) result = crypted_str.decode() except Exception: result = '加密失败,请确认输入是否有误!' return result def decrypt(self, text): generator = AES.new(self.key, self.mode,self.key) text += (len(text) % 4) * '=' try: decrpyt_bytes = base64.b64decode(text) meg = generator.decrypt(decrpyt_bytes) # 去除解码后的非法字符 result = re.compile('[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f\n\r\t]').sub('', meg.decode()) except Exception: result = '解密失败,请确认输入是否有误!' return result def main(): name = input("input uid:") sha1 = hashlib.sha1() sha1.update(name.encode('utf8')) #key = binascii.a2b_hex('8380cf291d73c51efb5351d7df0268cb89be530e'[:32])#秘钥的长度必须为16 key = binascii.a2b_hex(sha1.hexdigest()[:32]) result = 'HappyNewYearFrom52PoJie.Cn' cryptor = AESCBC(key)#这里选用的是CBC模式 plainText = cryptor.encrypt(result)#解密函数 print((plainText)) if __name__=="__main__": main()
版权声明:
本站所有资源均为站长或网友整理自互联网或站长购买自互联网,站长无法分辨资源版权出自何处,所以不承担任何版权以及其他问题带来的法律责任,如有侵权或者其他问题请联系站长删除!站长QQ754403226 谢谢。