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!

NOt working
ReplyDeletecan't run
ReplyDeleteThanks Dude it works Successfully in java as well as in android thank you for sharing
ReplyDeletewlcm bro
ReplyDeleteits working bro
ReplyDeletehi, 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?
ReplyDeleteHai, Rail Fence cipher was suppose to be "zig zag" right ? why does it arrange it descending order only??
ReplyDelete