Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
×
0 of .
Results for:
P. 1
Rail – Fence Cipher

# Rail – Fence Cipher

Ratings: (0)|Views: 6,762|Likes:
Rail – Fence Cipher Implementation using Java.
Rail – Fence Cipher Implementation using Java.

### Availability:

See More
See less

04/14/2013

pdf

text

original

Name: Dil Prasad Kuwor Date: 9/27/2010Roll no. : 064/02Subject: CryptographyAssignment no. : Lab No. 2
1
Q.5
Encrypt the text “WE ARE DISCOVERED FLEE AT ONCE”, to Rail –
Fence Cipher, using 3rails.
Cipher Text: - WECRL TEERD SOEEF EAOCA IVDEN
Java Code:
import java.util.*;class RailFenceCipher{public static void main (String[] args){Scanner in = new Scanner(System.in);int i=0,j,l,r,s,c=0,t=0;String plainText=" ",cipherText="";System.out.println("******RAIL-FENCE CIPHER******");System.out.println("Enter the plaintext:");plainText=in.nextLine();System.out.println("Enter the Rails:");r=in.nextInt();l=plainText.length()/r;s=2*l;char ct[][]=new char [r][s];while(i<r){ct[i][c]=plainText.charAt(t);t++;if(i==r-1&&t<=plainText.length()-1){c=c+1;for(j=r-2;j>=0;j--){ct[j][c]=plainText.charAt(t);t++;if(j==0&&t<=plainText.length()-1){c++;i=0;}}}i=i+1;}for(i=0;i<r;i++){for(j=0;j<ct[i].length;j++)

## Activity (17)

### Showing

AllMost RecentReviewsAll NotesLikes