// I need to

ModernizeUpgrade without breaking it RescueFix what someone else started Build NewTurn an idea into a product Reach More PeopleGet found, get used, include everyone

// Company

Case StudiesExpertiseAbout + CareersResourcesContact Book a call →

Looking at Steganography

Hiding a message inside an image with JavaScript, the HTML5 File API and canvas, and why making steganography easy to use is the real challenge.

Troy Farrel Jul 24, 20122 min read

From the Art+Logic archive · written in 2012. The tools may have moved on; the thinking still holds.

With the help of one of my favorite news aggregators, I discovered this article on using JavaScript and the canvas element to hide information inside images. I’ve long been fascinated by steganography and this article and demonstration makes it even more accessible. If you can’t be bothered to read the article, it describes a method of using the HTML5 File API and the canvas element to embed a message in images.

The challenge of steganography is making it accessible without making it obvious. Steganography fails when the presence of a hidden message is obvious. The art and science of detecting steganography has been a topic of study for years. There are papers on hiding messages. There are papers on finding those messages. There are papers on hiding multiple messages so you can reveal one and deny the presence of the other.

Let’s look briefly at how the aforementioned JavaScript and canvas tool changes our images. Here’s a white square:

Looking at Steganography

Here’s how I made it with ImageMagick:

$ convert -size 100x100 canvas:#ffffff white.png

Let’s embed the message “One if by land, and two if by sea;” in the white image with the password “Henry Wadsworth Longfellow”. Here’s what it looks like:

white_message.png

As you can expect with decent steganography, it’s hard to tell that there is a message embedded. Since only the least‐significant bits are being modified, the difference is subtle. Let’s look at the difference between the two images:

$ composite white.jpg white_message.png -compose difference white_difference.png

white_difference.png

That doesn’t seem to help much. The changes become much more obvious when we expand the contrast. Here’s what we get when we normalize the image:

$ convert white_message.png -normalize white_message_normalized.png

white_message_normalized.png

Now we can see what actually changed. Now this is a simple case, we had the source image and the image with the embedded message. However, it’s clear that the changes made to embed our image have generated a pattern atop the image.

In a future post, I’ll look at how software can look for these patterns.

keep going

More to explore in Reach More People.

All Reach More People resources →
let's talk

Got a problem like this one?

Tell us what's stuck. A real person replies within one business day.

Talk to our team →

Talk to people who know software, not a sales script.

Your first call is with Aja, our VP of Sales. He'll help make sure you're solving the right problem. Here's what you'll cover together:

  1. What you're trying to accomplish

    The business goal first, then the technology.

  2. Possible approaches

    And the tradeoffs of each, in plain language.

  3. Risks you may not have considered

    Technical and business, before they cost you.

  4. Whether AI changes the math

    What's practical, and what's just hype for your project.

  5. Sensible next steps

    Even if the right next step is not us.

book-a-call.ics

Loading the scheduler…

Open the booking page →

Some problems are easier to explain in writing. Send us a few lines about what you're working on, and we'll reply within one business day. Helpful to include:

  1. What the software does, or should do
  2. What's stuck, or what's worrying you
  3. Any deadline or budget you have in mind
note.md

Loading the form…