Rail Fence Cipher

Steph Leung on Flickr

A simple zigzag pattern can scramble your messages beyond recognition.

In the last two issues, we’ve been exploring ciphers that use simple substitution. The first swapped letters of the alphabet around, which the second used ‘pigpens’ to designate each letter then used them to deliver an encrypted code. This issue, we’re going to be looking at a code that doesn’t simply replace letters with other symbols!

This is the case for the Rail Fence Cipher, a very interesting way of delivering messages. We’ll still be sending normal-looking letters as our message, but it’ll be so scrambled up that anyone who doesn’t know the code won’t know what it says. Even better, unlike simple substitution, it’s not just regular letters interchanged with other ones, meaning it’s a little trickier to crack!

So, let’s explore how you make a more complicated code with the Rail Fence Cipher. To start with, think of a message you want to send. For this example, we want to send the message “HELLO WORLD”.

Then, decide on the amount of ‘rails’ you want to use. For this example, and a good starting point in general, we’re going to use three rails. However many rails you choose, draw them out like this:


Become a subscriber and get access to the rest of this article. Plus all our magazine articles.

Stories also include numerous links to help parents, kids, and teachers learn more. Get access today at just $15 per year!

Subscribe Today!

Also In The December 2017 Issue

Learn some nifty coding tricks while creating a Formula EV3 Race Car.

With binary search, you don’t have to be a mind reader to beat this simple coding activity.

Controllers have come a long way in 50 years. Let’s appreciate the bulky, awkward ancestors that led us here!

Take your Scratch games to the next level by adding multiple modes with multiple sprites.

Let the CSS Zen Gardens wow you with variety and elegance. Making a pretty website isn’t so complicated after all!

An introduction to a hip new alternative to Java. It’s all the rage in android development!

Resources to transform you into a web virtuoso, from messaging apps to testers to code converters.

New treasures and new enemies await in two unique, dangerous realms.

Create your own 3D digital museum and learn how you can help preserve cultural artifacts.

Interesting stories about computer science, software programming, and technology for December 2017.

Add data types to your new programming language in this third installment of the series.

Links from the bottom of all the December 2017 articles, collected in one place for you to print, share, or bookmark.