Home 0P3N Blog Hide Secret Message Inside an Image Using LSB-Steganography
Ready to Start Your Career?
Create Free Account
By: Shaquib Izhar
March 7, 2018

Hide Secret Message Inside an Image Using LSB-Steganography

By: Shaquib Izhar
March 7, 2018
By: Shaquib Izhar
March 7, 2018
Imagine a scenario where we want to send a confidential message and don't want anyone except the recipient to read it. We will use every possible methods to make our message hidden from any third person. So here I am going to use LSB-Steganography method to hide our message inside an image.

What is LSB
Least Significant bit also called RightMost Bit is a lowest bit of a binary number. For example in binary number 10010010, "0" is the least significant bit.

What is LSB-Steganography
LSB-Steganography is a steganography technique in which we hide messages inside an image by replacing Least significant bit of image with the bits of message to be hidden. By modifying only the first most right bit of an image we can insert our secret message and it also make the picture unnoticeable, but if our message is too large it will start modifying the second right most bit and so on and an attacker can notice the changes in picture.

Let's hide our message

STEP 1: Before hiding our secret message we will make sure to make it fully encrypted so if someone extracted the message from the image he would not able to get the secret message. So first we will create our secret key, for this i will open nano (you can use whatever you want ) by typing nano file.txt then press return and then i will enter my secret key then exit.



STEP 2: We will encrypt our message with symmetric key algorithm using gpg so that both the sender and receiver will only need a single key for encryption and decryption. So type gpg -c msg.txt to encrypt it. ( I am using CAST 128 cipher for encryption.)



STEP 3: It will ask for password so enter your desire password.



STEP 4: I will upload this encrypted message to some hosting server and then copy the downloadable link to hide it in our image.

STEP 5: Now type got clone https://github.com/RobinDavid/LSB-steganography.git and move into this directory.



STEP 6: Install the dependencies by typing pip install -r requirements.txt.

STEP 7: To hide the message type python LSBSteg.py -i "your image in which you want to hide your messge" -o "output of the image file with the format" -f "text file which you want to hide".



Our image file has prepared.



Extracting the hidden message Our recipient has receive has received the image file and its time to reveal the hidden message from this image.

STEP 1 To decode the hidden data from the image type decode -i "your image file contain messgae" -o " output name with file format".



STEP 2 We have extracted the file from the image now its time to read content from it so type cat msg.txt to read the file.



STEP 3 After downloading the file its time to decrypt it so type gpg -d  "your encrypted file", it will ask for password enter it and then we will get our secret message.



For more stuff you can follow us on : Facebook
Request Demo

Build your Cybersecurity or IT Career

Accelerate in your role, earn new certifications, and develop cutting-edge skills using the fastest growing catalog in the industry