Tuesday, May 07, 2019

Visual Cryptography Part 2 - Like Magic!

I finished my implementation of the visual cryptography algorithm. Doing so was even more rewarding than I imagined.

Here's how it works. First, you sketch out your message:

Then you hit the 'Encrypt' button. The result are two images that look like random noise:

Incidentally, the images look like random noise because that's exactly what they are. When I was building the code to power this demo I had various errors that didn't properly randomized the filling of pixels. This resulted in traces of the original image being visible. When properly implemented, the generated images look like nothing but scattered black pixels.

Clicking 'Decrypt' is where the magic starts to happen. The two images slide over each other, revealing nothing of note:

When the images are finally and precisely overlaid, the message pops back into view:

You'll notice that the image background is now gray and not white. That's because every two white pixels are replaced by a black and white pair. This is what provides noise in both images, yet what allows for a final image to be legible.

I'm not sure how I can turn this demo into a practical tool, but you know I'm going to try.

You can find the source code for the demo here and try your hand at visual cryptography here.

No comments:

Post a Comment