Classical Cryptography
Rail Fence Cipher
The Rail Fence Cipher is a transposition cipher. It writes the plaintext in a zigzag pattern across rails and reads row by row.
Algorithm Steps
- 1Take plaintext input.
- 2Take rail depth input.
- 3Write characters in zigzag pattern.
- 4Read each rail row by row.
- 5Combine rows to form ciphertext.
Formula
Characters are arranged in a zigzag pattern using the selected rail depth.
Example
Plaintext: WEAREDISCOVEREDFLEEATONCE Depth: 3 Encrypted text: WECRLTEERDSOEEFEAOCAIVDEN Decrypted text: WEAREDISCOVEREDFLEEATONCE