TroyDev

Combining Steganography with Cryptography

Steganography is the art of hiding information in images, cryptography is the practice of hiding information from adversaries. I was interested in creating an unbreakable and undetectable encryption so I began by looking into 1) how information was discerned from noise and 2) how codes were cracked.

Basically both of those problems are the same, Hidden information is found and codes are cracked by finding patterns. This can be got around by having no pattern, or at least having so many ways to encode each letter of the alphabet, each character is encoded in a unique hash. In this way, a long string of encoded Zs would not leave a repeating pattern which could be detected.

The information is encoded 16 bits of data, therefore 65536 different unique characters can be encoded, if we only want to encode 26 letters of the alphabet, spaces and some character to signify the end of the message, that leaves us with 2340 possible permutations per letter. The information is then hidden in the images in a 4x4 pixel grid pattern. Each pixel in the image is represented by an integer which can be odd or even, if you read even as 0 and odd as 1 you have binary information.

28 unique characters can be stored using only 5 bits of data, therefore the process of increasing the number of bits used to store each character could be seen as hashing. To convert a message into string of hashes, a neural network and backwards engineering is used. A random 16bit configuration is chosen, passed through the neural net and the if it is needed, the character it represents is inserted into the message, this process is repeated until each character in the message has a random 16 bit hash assigned. This makes decrypting the message easy, if you have the correct neural network, simply pass each hash through the network and voila, your secret message!

Of course, if you don't have the neural network, all you'll see is an image, and even if you know there is a message inside it, the chances of the message containing two identical 16 bit hashes is small. A message which is 3000 characters long would therefore look like it was written in a language which used 3000 letters in its alphabet. The network used to create the hashes is highly sensitive to even small tweaks to its structure, so much so that even a single node with an altered threshold will output gibberish that is impossible to replicate without the original parameters.

Try it yourself: Encrypt.jar

Source code (MIT License): Github

View Image View Image View Image

Download the images containing the hidden messages: Basic hidden message, Password protected message

  • Due to the nature of the encryption any form of image compression will destroy the hidden message therefore sending an image with a secret message over Facebook will not work.
  • I'm not familiar with the industry standard methods for encrypting data and can take no responsibility for your secrets being exposed while using my encryption method.

Help

If you are having trouble running the program, please try this quick guide.

Simple instructions

  • Rename a .png or .jpg to a message that you want hidden inside it
  • For ease of use, move the image into the same folder as the program
  • Run the program, select the image and click "OK"
  • Click "Cancel" to finish or select another file to encode it as well
  • You will find your image has been renamed, you can now change it to whatever you like and your secret message is safe
  • To retrieve your message Run the program again Select the image and click "OK"
  • You will find your image has been renamed back to the original message that you encoded (minus punctuation or capital letters).

Advanced instructions

To run the program from a command line or console, open the console to the location of the program and type "java -jar Encrypto.jar" You can also add extra arguments to the JVM for extra features of the program, "java -jar [add your arguments here] Encrypto.jar" these are:

  • '-Dseed=integer' This allows you to specify your own seed, used to construct the Neural Network, messages encoded with a seed can only be decoded with exactly the same seed allowing for "passkey" protected messages (default value if unspecified == 1198662804)
  • '-Dleeway=float' This allows you to control the inner workings of the Network used to encode and decode messages, again changing this value will change how the network translates information. This value is very sensitive and it is recommended that you use some of the other modes in order to refine this variable if you intend to change it. (default value if unspecified == 0.07)
  • '-Dmode=mode' This allows you to change what mode the program is run in which are:
    • dictionary, this mode simply cycles through every combination 16 bits can represent and prints out the character that the Network represents it as. This can be helpful in assessing how randomly our Network is assigning characters to our 16 bit combinations
    • stats, this mode calculates the frequency of combinations that represent each letter of the alphabet, it then prints out the Standard Deviation of the frequencies and also an array representing the % of combinations used for each letter. A pseudo random distribution of frequencies would result in a standard deviation of roughly 100 though 400 is a good number to aim for when choosing a seed.
    • optimise, this mode allows you to search for a seed with a low standard deviation for a particular setup, you can specify the 'levels' used in the Network and the 'leeway' with the above parameters.
    • graph, this mode draws a graph to an image and saves it to your desktop. This mode is most useful for narrowing down an appropriate 'leeway' value. The graph shows the standard deviation for a range of Networks with leeway set between:
      • '-Dminleeway' (default if unspecified == 0.0)
      • '-Dmaxleeway' (default if unspecified == 0.4)

Devlopment Log

~ February 2014 ~

This version is very simple, in the future I intend to make it more user friendly however it works and for now I need to concentrate on Uni work.

Messages can be hidden in messages and retrieved from them. The program reads any information hidden in the message and grabs the name of the image and then swaps them round, hiding the name in the image and renaming it to anything hidden in the image.

Try it yourself: Encrypt.jar

  • This version doesn't have a GUI.
  • Messages can be encoded and decoded from images, through the rather clunky process of renaming them and running this program.