previousMenunext

Rail Fence Cipher

Functionality and example

The Rail Fence Cipher does work similar to "Scytale" (quod vide "Scytale"). It is a form of transposition cipher. In the rail fence cipher, the plaintext is written downwards and diagonally on successive "rails" of an imaginary fence, then moving up when we reach the bottom rail. When we reach the top rail, the message is written downwards again until the whole plaintext is written out. The message is then read off in rows.

Example:

The plain text "FRONT DOOR" written with key = 2 (means two rows among each other) will result in "FOTORRNDO"



Operation



Input
  1. Text, that shall be encrypted or decrypted
  2. The number of characters, that shall be written on every fence (e.g. 2)
  3. Mode, encryption or decryption
Output
The resulting text