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 this. 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.
My implementation is quite simple and can be explained in three simple steps. I’ve used Autohotkey
for coding it because it is quite simple and I often use it because of its simplicity
and 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 and 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:
Yes, it is 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 Data From the Image
The data written onto the image file can be retrieved by reading the last line from the file
and decrypting it using the key that was used to encrypt the message.
Only the last line of the file is read, meaning if the same image is used before, the message which was added last will be read
There is no check done to verify whether the image contains any data, but that can be implemented easily with a few lines of code in
The code for embedding the message:
;Simple Message Embedding - Encryptor
InputBox,data,Enter Message,Enter The Message To Be Embedded Into The Image
InputBox,pass,Enter Encyrption Key,Enter Password To Encrypt
FileSelectFile, SelectedFile, 3, , Select an image, Image Files (*.jpg; *.png)
if SelectedFile =
MsgBox, Select A File!
MsgBox,The Message will be hard coded into the file :`n%SelectedFile%
Msgbox,0,Done,The Message Was Embedded!
;Function To Encrypt The Message
Format := A_FormatInteger
SetFormat Integer, Hex
b := 0, j := 0
a := A_Index - 1
,Key%a% := Asc(SubStr(Pass, Mod(a,StrLen(Pass))+1, 1))
,sBox%a% := a
a := A_Index - 1
,b := b + sBox%a% + Key%a% & 255
,sBox%a% := (sBox%b%+0, sBox%b% := sBox%a%) ; SWAP(a,b)
Loop Parse, Data
i := A_Index & 255
,j := sBox%i% + j & 255
,k := sBox%i% + sBox%j% & 255
,sBox%i% := (sBox%j%+0, sBox%j% := sBox%i%) ; SWAP(i,j)
,Result .= SubStr(Asc(A_LoopField)^sBox%k%, -1, 2)
StringReplace Result, Result, x, 0, All
SetFormat Integer, %Format%
Points of Interest
The implementation is bound to certain limitations. The first one, like other ones out there, is the loss of message during conversion or resizing.
The encryption I have used here is not powerful enough. No check is performed
for the existence of messages on file.