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.
This is program for Rail Fence Cipher JAVA.
public class railfence {
public static void main(String args[])
{
String input = "inputstring";
String output = "";
int len = input.length(),flag = 0;
System.out.println("Input String : " + input);
for(int i=0;i<len;i+=2) {
output += input.charAt(i);
}
for(int i=1;i<len;i+=2) {
output += input.charAt(i);
}
System.out.println("Ciphered Text : "+output);
}
}
This is program for Rail Fence Cipher JAVA.
public class railfence {
public static void main(String args[])
{
String input = "inputstring";
String output = "";
int len = input.length(),flag = 0;
System.out.println("Input String : " + input);
for(int i=0;i<len;i+=2) {
output += input.charAt(i);
}
for(int i=1;i<len;i+=2) {
output += input.charAt(i);
}
System.out.println("Ciphered Text : "+output);
}
}
can you please post the code for decryption using railfence in java
ReplyDelete