Skip to content

Instantly share code, notes, and snippets.

@DoMINAToR98
Created March 24, 2019 19:28
Show Gist options
  • Save DoMINAToR98/101e5c4933c5c10d42d16e25b3890821 to your computer and use it in GitHub Desktop.
Save DoMINAToR98/101e5c4933c5c10d42d16e25b3890821 to your computer and use it in GitHub Desktop.
Code for LSB-Steganography
from PIL import Image
import binascii
im = Image.open('pic.png')
pix_val = list(im.getdata())
# print pix_val
lsbs=""
for idx,val in enumerate(pix_val):
# Converting each rgb values into binary and keeping only the Least Significant Bit
lsbs=lsbs+'{0:08b}'.format(val[0])[-1]
lsbs=lsbs+'{0:08b}'.format(val[1])[-1]
lsbs=lsbs+'{0:08b}'.format(val[2])[-1]
n=int(lsbs,2)
# Converting binary to ascii
print binascii.unhexlify('%x' % n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment