664104f6 by 冯轩

MOD:统一处理x0字符

1 parent c8bacd75
1 from Crypto.Cipher import AES 1 from Crypto.Cipher import AES
2 from base64 import b64encode, b64decode 2 from base64 import b64encode, b64decode
3 import re
3 4
4 def aes_encrypt_cbc(data, key, iv): 5 def aes_encrypt_cbc(data, key, iv):
5 cipher = AES.new(key, AES.MODE_CBC, iv) 6 cipher = AES.new(key, AES.MODE_CBC, iv)
...@@ -10,7 +11,8 @@ def aes_decrypt_cbc(data, key, iv): ...@@ -10,7 +11,8 @@ def aes_decrypt_cbc(data, key, iv):
10 try: 11 try:
11 cipher = AES.new(key.encode(), AES.MODE_CBC, iv.encode()) 12 cipher = AES.new(key.encode(), AES.MODE_CBC, iv.encode())
12 res = cipher.decrypt(b64decode(data)) 13 res = cipher.decrypt(b64decode(data))
13 res = res.decode('utf-8').replace('\x0e', '').replace('\u0007', '') 14 # res = res.decode('utf-8').replace('\x0e', '').replace('\u0007', '').replace('\x08', '')
15 res = re.sub(r'[\x00-\x0f]', '', res.decode('utf-8'))
14 except Exception as e: 16 except Exception as e:
15 res = '' 17 res = ''
16 return res 18 return res
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!