Steganography Starting Code

Solve It

One of the disadvantages of sending encoded messages is that people who enjoy solving puzzles (like us!) will always try to crack the code. Steganography, on the other hand, is a sneakier way of transmitting secrets because if it is done correctly it is not apparent that there is any message being sent at all. Steganography is the process of hiding a message like a text string, picture, or file within another text string, picture, or file. For example, imagine that I send a secret message to you by taking a book and circling some of the letters in the book with invisible ink. When you receive the book, you can look at the pages under a special light and see the letters I have chosen, which of course spell out some very important secret. The text of my secret is hidden within an innocent-looking text. Anyone else who looks at the book would not be suspicious or try to crack the code, because they would not even know that there was a code present.

Steganography examples are especially fun when they are images. Since "everything’s a number”, we know that images are really made up of a series of red, green, and blue numeric values. It turns out that if we change the values of these numbers slightly, our eyes really can’t tell the difference in the colors. If a color has a red value of 237, for example, it may look no different from a color with red value anywhere between 230-239. The last digit does not change the hue enough to notice. Since part of the numbers don’t really matter in terms of how the overall picture looks, those numbers become a great place to hide information. That last digit is like one of the circled letters in the secret book. If you look at enough of these secret hiding spots and put the information together, a new message is revealed.

Note, the code in this example sets the hide image to the result of dividing every pixel by 16 so all the colors' component values are all low numbers (i.e., 16 or less), making the entire image look basically black.

Code It

// steganography function pixchange(pixval){ var x = Math.floor(pixval/16) * 16; return x; } function chop2hide(image){ for(var px of image.values()){ px.setRed(pixchange(px.getRed())); px.setGreen(pixchange(px.getGreen())); px.setBlue(pixchange(px.getBlue())); } return image; } function shift(im){ var nim = new SimpleImage(im.getWidth(), im.getHeight()); for(var px of im.values()){ var x = px.getX(); var y = px.getY(); var npx = nim.getPixel(x,y); npx.setRed(Math.floor(px.getRed()/16)); npx.setGreen(Math.floor(px.getGreen()/16)); npx.setBlue(Math.floor(px.getBlue()/16)); } return nim; } var start = new SimpleImage("usain.jpg"); var hide = new SimpleImage("skyline.jpg"); start = chop2hide(start); hide = shift(hide); print(start); print(hide);

See It

 
 

Available Images


rodger.png
[315x424]

smallmessage.png
[256x200]

MessageCSEveryone.jpg
[278x409]

astrachan.jpg
[240x360]

duvall.jpg
[200x300]

hilton.jpg
[140x210]

skyline.jpg
[300x300]

smalluniverse.jpg
[256x200]

usain.jpg
[300x300]

Drop your images onto the area above to make it available within your code editor on this page. Note: your images will not be uploaded anywhere, they will stay on your computer.