8.3 Cracking the Rail Fence

We can write a generalized version of the transposition cipher called the rail fence cipher. In this section, we will look at a brute-force technique to break a two-rail fence with the odd and even characters placed into separate rails. Let’s begin by reviewing the procedure for the rail fence.

The key to the rail fence cipher is the number of rails used. When you know the number of rails, you encrypt the message by filling the rails top to bottom and left to right. For example, let’s suppose we want to encrypt the message “new ipad coming tomorrow” using three rails.

A table for Cracking the Rail Fence.

Description

Once we have constructed the rails, ...

Get Python Programming in Context, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.