我正在编写一个Python来处理日志文件。该程序在两种模式之间解密base64编码的字符串。每当我运行代码时,我得到"不正确的填充错误"
这是我的代码
import static org.jooq.impl.DSL.*;
答案 0 :(得分:1)
因为这是85的基础!不是基地64!试试这个:
import base64
import binascii
import re
def find_between_r(s, first, last):
try:
start = s.rindex(first) + len(first)
end = s.rindex(last, start)
return s[start:end]
except ValueError:
return ""
text = '192.168.1.23 - - [18/Jun/2015:12:16:12 +0200] "GET /admin/?action=membres&order=QVNDLChzZWxlY3QgKGNhc2UgZmllbGQoY29uY2F0KHN1YnN0cmluZyhiaW4oYXNjaWkoc3Vic3RyaW5nKHBhc3N3b3JkLDE3LDEpKSksMSwxKSxzdWJzdHJpbmcoYmluKGFzY2lpKHN1YnN0cmluZyhwYXNzd29yZCwxNywxKSkpLDIsMSkpLGNvbmNhdChjaGFyKDQ4KSxjaGFyKDQ4KSksY29uY2F0KGNoYXIoNDgpLGNoYXIoNDkpKSxjb25jYXQoY2hhcig0OSksY2hhcig0OCkpLGNvbmNhdChjaGFyKDQ5KSxjaGFyKDQ5KSkpd2hlbiAxIHRoZW4gVFJVRSB3aGVuIDIgdGhlbiBzbGVlcCgyKSB3aGVuIDMgdGhlbiBzbGVlcCg0KSB3aGVuIDQgdGhlbiBzbGVlcCg2KSBlbmQpIGZyb20gbWVtYnJlcyB3aGVyZSBpZD0xKQ%3D%3D HTTP/1.1" 200 1007 "-" "-"'
result = re.search('order=(.*) H', text)
t = result.group(1)
print(base64.b85decode(t))