Write Java program to Implement Rail Fence Cipher

Ram Pothuraju
Cryptography

Rail Fence Cipher

Interactive Java implementation — encrypt and decrypt text using the columnar rail fence transposition technique

Encryption

Writes plaintext column-wise into a matrix, then reads row-wise to produce ciphertext

Decryption

Writes ciphertext row-wise into a matrix, then reads column-wise to recover the original text

Depth Key

The depth value determines the number of rows in the transposition matrix

Java Source

Full source code below — copy and compile directly with javac

Run the Cipher
Console Output
// Ready. Click Encrypt or Decrypt to run the Rail Fence Cipher. // This exactly mirrors the Java program's logic in-browser.
Java Source Code
RailFence.java
Copied to clipboard!

Post a Comment

7Comments

  1. Thanks Dude it works Successfully in java as well as in android thank you for sharing

    ReplyDelete
  2. hi, how would add an offset to this so that the user can input the starting row for the plain text to be added into the array?

    ReplyDelete
  3. Hai, Rail Fence cipher was suppose to be "zig zag" right ? why does it arrange it descending order only??

    ReplyDelete
Post a Comment