Skip to main content
Home
plus.maths.org

Secondary menu

  • My list
  • About Plus
  • Sponsors
  • Subscribe
  • Contact Us
  • Log in
  • Main navigation

  • Home
  • Articles
  • Collections
  • Podcasts
  • Maths in a minute
  • Puzzles
  • Videos
  • Topics and tags
  • For

    • cat icon
      Curiosity
    • newspaper icon
      Media
    • graduation icon
      Education
    • briefcase icon
      Policy

    Popular topics and tags

    Shapes

    • Geometry
    • Vectors and matrices
    • Topology
    • Networks and graph theory
    • Fractals

    Numbers

    • Number theory
    • Arithmetic
    • Prime numbers
    • Fermat's last theorem
    • Cryptography

    Computing and information

    • Quantum computing
    • Complexity
    • Information theory
    • Artificial intelligence and machine learning
    • Algorithm

    Data and probability

    • Statistics
    • Probability and uncertainty
    • Randomness

    Abstract structures

    • Symmetry
    • Algebra and group theory
    • Vectors and matrices

    Physics

    • Fluid dynamics
    • Quantum physics
    • General relativity, gravity and black holes
    • Entropy and thermodynamics
    • String theory and quantum gravity

    Arts, humanities and sport

    • History and philosophy of mathematics
    • Art and Music
    • Language
    • Sport

    Logic, proof and strategy

    • Logic
    • Proof
    • Game theory

    Calculus and analysis

    • Differential equations
    • Calculus

    Towards applications

    • Mathematical modelling
    • Dynamical systems and Chaos

    Applications

    • Medicine and health
    • Epidemiology
    • Biology
    • Economics and finance
    • Engineering and architecture
    • Weather forecasting
    • Climate change

    Understanding of mathematics

    • Public understanding of mathematics
    • Education

    Get your maths quickly

    • Maths in a minute

    Main menu

  • Home
  • Articles
  • Collections
  • Podcasts
  • Maths in a minute
  • Puzzles
  • Videos
  • Topics and tags
  • Audiences

    • cat icon
      Curiosity
    • newspaper icon
      Media
    • graduation icon
      Education
    • briefcase icon
      Policy

    Secondary menu

  • My list
  • About Plus
  • Sponsors
  • Subscribe
  • Contact Us
  • Log in
  • Two Cogs from an enigma machine

    The rail fence cipher

    1 March, 2008
    March 2008

    Enigma machine

    The Enigma machine was used by the Germans to encode messages in WW2.

     

    Let's get codebreaking.

    The rail fence cipher involves writing messages so that alternate letters are written on separate upper and lower lines. To create the final encrypted message, the sequence of letters on the upper line is then followed by the sequence on the lower line. The code maker improves the security of the cipher by choosing more than two lines to encrypt the message.

    Take the plaintext "pancakes for breakfast" for example. It can be enciphered using a shift of two by writing it as follows:

    p n a e f r r a f s 
     a c k s o b e k a t

    The ciphertext is then created by reading across the rows as follows:

    pnaefrra fsa cksobekat

    In this case, a shift of two, in other words two lines, was used. In order to decipher it, the ciphertext must be split into two parts. If the shift was three, then the ciphertext must be split into three lines, four lines for a shift of four etc.

    Here is your cypher text. You'll have to work out for yourself which shift was used. Happy puzzling!

    TURNITYLNTHASMTITLRBAQEC.SONEASEBEWBMSASEB'BNODOENNIVH
    MTTXRBLTIELTBHSAIOUSUWHITNURTQZEEOEBANODISEBLIMTTTXEEBW
    YIURI.SSLNEANPNMTAAHITHLMTIUETNCNENULRCCCEVNOHWYMSNEESS
    LIAITMEURT'ADEHSRISIEYBHSEDWTUURDNVUKUASENRAESO.

    You can find out more about the rail fence cypher on Simon Singh's website.



    If you are stumped by last issue's puzzle, here is the solution.

    For some challenging mathematical puzzles, see the NRICH puzzles from this month or last month.

    Solution link
    Rail fence cipher solution
    • Log in or register to post comments
    University of Cambridge logo

    Plus is part of the family of activities in the Millennium Mathematics Project.
    Copyright © 1997 - 2025. University of Cambridge. All rights reserved.

    Terms