Advertisement
foryou97

Xor2Image

Aug 16th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from PIL import Image
  2.  
  3. # Picture is 19*19 pixels wide and 19*19 pixel high
  4. img = Image.open('stego_100_f78a3acde659adf7ceef546380e49e5f')
  5. m1 = m2 = ''
  6.  
  7. # Each 19x19 block represents 1 (white) or 0 (black)
  8. for y in range(0, img.size[0], 19):
  9.     for x in range(0, img.size[1], 19):
  10.         r,g,b,a = img.getpixel((x,y))
  11.         m1 += str(r & 1) #
  12.  
  13. # Get the binary representation of the center 19x19 block
  14. for y in range(171, 171 + 19):
  15.     for x in range(171, 171 + 19):
  16.         r,g,b,a = img.getpixel((x,y))
  17.         m2 += str(a & 1)
  18.  
  19. # xor both
  20. xor = ''.join(str(int(A)^int(B)) for A,B in zip(m1,m2))
  21. # get the ascii representation of the binary stream
  22. print ''.join(chr(int(xor[i:i+8], 2)) for i in range(0, len(xor), 8))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement