Guest User

Untitled

a guest
May 11th, 2017
127
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with open('target', 'rb') as f:
  2.     target = f.read()
  3. png = ''
  4. i = 0
  5. while i < len(target):
  6.     bitmap = '{0:08b}'.format(ord(target[i]), 'b')
  7.     i += 1
  8.     for bit in bitmap:
  9.         if bit == '0':
  10.             png += target[i]
  11.             i += 1
  12.         else:
  13.             b = '{0:08b}'.format(ord(target[i]), 'b') + '{0:08b}'.format(ord(target[i + 1]), 'b')
  14.             offset = int(b[0:12], 2)
  15.             amount = int(b[12:16], 2)
  16.             png += png[offset: offset + amount]
  17.             i += 2
  18. print ''.join('{:02x}'.format(ord(c)) for c in png)
RAW Paste Data