Skip to content

Instantly share code, notes, and snippets.

@jimmy-ly00
Created September 7, 2017 12:04
Show Gist options
  • Save jimmy-ly00/342bf8987db526689dfa374f161b93f0 to your computer and use it in GitHub Desktop.
Save jimmy-ly00/342bf8987db526689dfa374f161b93f0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
with open("sample.bmp", "rb") as file:
data = file.read()
bits = ""
for c in data:
lsb = str(c & 0x1)
bits += lsb
bytes = [chr(int(bits[i:i+8], 2)) for i in range(0, len(bits), 8)]
out = "".join(bytes)
print(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment