Embed Secret Messages On Photos Easily

Posted by in Experiments, Technology, Tutorials

Computer Security

The idea of embedding secret messages on images is not new, in fact this has been done many times by many people. Some are so complex that even experts in Steganography won’t be able to decrypt them. I’ve used a simple method to do the same. Data can be written into files in binary mode without modifying the initial contents of the file. This is the basic idea of my implementation.

Embedding The Data

My implementation is quite simple & can be explained by 3 simple steps. I’ve used Autohotkey for coding it because its quite simple & i often use it because of its simplicity & power. If this was done in any mainstream programming language like C/C++, it would take almost twice or thrice the number of code lines. Autohotkey, which is a scripting language originally developed for automating keystrokes & mouseclicks, was taken to the next level by the community. Now, autohotkey is one of the most powerful scripting languages known, which is capable of doing almost everything a normal programming language can do.

The algorithm for the encryptor can be explained like this:

Algorithm For Encryption

Yes, its as simple as this! Writing to file is the tricky part, the FileAppend command in Autohotkey supports writing in binary mode, which will not corrupt the file being written. The encrypted message is written at the end of the file. If the same image is used, the previous message will be lost(the program may be modified to read all the messages with some minor changes).

Decrypting The Data From Image

The data written onto the image file can be retrieved by reading the last line from the file & decrypting it using the key that was used to encrypt the message.

Decryption Algorithm

Only the last line of the file is read, meaning if the same image is used before, the message which was added lastly will be read &  decoded. There is no check is done to check whether the image contains any data, but can be implemented easily with a few lines of code in autohotkey.

Try It!(Autohotkey Code,  No Executable!)

Inorder to run these examples, you need Autohotkey Installed. I’ve used Autohotkey v1.1.09.01. You can download Autohotkey directly from here. The source code is provided “As-IS”, i’m not responsible for anything! You may freely modify the code.

Encryptor – For Embedding Messages

Decryptor – For Reading Embedded Messages

How to run

1) Download & Install autohotkey from the above link

2) Download the Encryptor/Decryptor by right clicking & selecting “Save Link As”

3) Double click on the .AHK files to run the examples!

Limitations

The implementation is bound to certain limitations. The first one is, like other ones out there, is the loss of message during conversion or resizing. The encryption i’ve used here is not powerful enough. No check is performed about the existence of message on file.

Happy embedding!  😉