The rail fence cipher is where we write down plaintext as a sequence of diagonals and then read off as a sequence of rows.

Example

To decrypt: reconstruct the diagonal grid used to encrypt the message

  • Start by making a grid with as many rows as the key is, and as many columns as the length of the ciphertext
  • Place the first letter in the the top left square, and dashes diagonally downwards where the letters will be
  • When we get back to the top row, we place the next letter in the ciphertext
  • Continue like this across the row, and start the next row when you reach the end