How To Hide Secret Messages In Images With Linux

March 7, 2011 by
Filed under: HowTo, image editing, linux 

In today's post I'm going to show how to embed a text message into an image file. This type of messaging is known as steganography. Steganography is the practice of hiding secrets in such a way that only the intended message recipient would know to look for your hidden message.

In this basic form of secret messaging we'll be adding text onto the end of a file. I'm going to use the following image of Tux for my example. 

Tux the penguin

You can save the above image to give it a try, or you can just use an image that you already have. I'm going to show two ways to do this. In the first example I'll show how to enter your message interactively. In the second example I'll show how to take a message saved in a text file and append it to the end of the image file.

Affiliate Link

Enter your message interactively

Open a terminal window and navigate to the directory where your image is stored. Now we'll use the cat command to append text to the end of the image file.

cat ShinyTux.png - >secret.png

The cursor should now be blinking, waiting for you to enter your message from standard input. Start off by hitting [Enter] to create a blank line. This will make it so your message starts on a new line at the end of the file. Now just type in the rest of your secret message. Hit [Enter] one more time when you're done, then hit [Ctrl]+[D] to exit.

Now, if you want to read your secret message from the file, just use

tail secret.png
Tux with a secret

Tux with a secret message

Embed a message using a text file

In the second example we're going to save the secret message in a text file first, then append it to the end of an image.

Open your favorite text editor and create your secret message. Make sure to leave an empty line at the beginning of the text file to make it easier to distinguish your message later. Now save the file as message.txt.

Now there's a couple of ways to approach adding the message to your image. You can take your message and image and merge them into a new file like this.

cat ShinyTux.png message.txt >secret.png

Or you can append your message to the end of the original image like this.

cat message.txt >>ShinyTux.png

Do you know some other ways to hide messages within a file? Leave a comment.

Comments

4 Responses to “How To Hide Secret Messages In Images With Linux”

  1. EMMA says:

    thx but abit was trouble to decrypt cause U didn't show how to view the file from the pic but tried
    "cat secret.png > message.txt " then viewed the file ,hope it helps

  2. Alex says:

    thanks for this useful tips

  3. Steghide is also quite good fun! http://www.ubuntucymraeg.org/?p=758

    steghide embed -cf ffotograff.jpg -ef neges.txt

    where ffotograff.jpg is the image and neges.txt is the message you want to hide.

    Thanks for the geat tips on the blog.

  4. Prakash R says:

    Cool ! I found a similarly interesting article on installing wallpaper clocks at http://ubuntumanual.org/posts/246/installing-wallpaper-clock-in-ubuntu-in-3-simple-steps .Check it out !

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>