- Two picture, one is brighter. "Can you tell the difference?" and a comment says it's more easy than I think.
- Just visit http://www.pythonchallenge.com/pc/return/brightness.html and you will see the same page.....wait! The comment changes..."maybe consider deltas.gz"!
- Download "deltas.gz" from http://www.pythonchallenge.com/pc/return/deltas.gz and extract delta.txt.
- Two similar data sets showed in this file. Both of them start with "89 50 4E 47 0D ..."
- According to https://en.wikipedia.org/wiki/List_of_file_signatures, "89 50 4E 47 0D 0A 1A 0A" is a hex signature of PNG file!
- We should "tell the difference" of these two data set. A simple and easy way is use difflib.
- See also: https://docs.python.org/2/library/difflib.htmlimport difflib
f = open("delta.txt")
left_data = []
right_data = []
for line in f:
left_data.append(line[0:len(line)/2].strip())
right_data.append(line[len(line)/2:len(line)].strip())
if left_data[-1] == "": left_data.pop()
if right_data[-1] == "": right_data.pop()
f.close()
diff = list(difflib.ndiff(left_data, right_data))
diff_space = []
diff_plus = []
diff_minus = []
for i in diff:
if i[0] == " ": diff_space.extend(i[2:].split())
elif i[0] == "+": diff_plus.extend(i[2:].split())
elif i[0] == "-": diff_minus.extend(i[2:].split())
space = open("space.png", "wb")
plus = open("plus.png", "wb")
minus = open("minus.png", "wb")
for i in diff_space:
space.write(chr(int(i, 16)))
for i in diff_plus:
plus.write(chr(int(i, 16)))
for i in diff_minus:
minus.write(chr(int(i, 16)))
space.close()
plus.close()
minus.close()
- The three result pictures are look like:- The next level is http://www.pythonchallenge.com/pc/hex/bin.html, username and password are "butter" and "fly".
沒有留言:
張貼留言