Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
11-04-2006, 10:02 AM #1
- Join Date
- Nov 2006
- Thanked 0 Times in 0 Posts
transposition cipher - very urgent!
i'm very new to java and i'm having a very hard time with an assignment, i hope that somebody can help..
here's what i've been asked:
A transposition cipher first chooses a key to number the columns, then write a plaintext in rows, and finally reads
the ciphertext by columns, staring with the column whose key letter is the lowest alphabetically. Shown below is
one example whereby a string ‘jamesbond’ is used as the key:
s e n d o n e send one million euros to my swiss
mi l l i on e bank account
uros to m
y s w i s s b ciphertext :
EIR NTOOTSCG EMBUADLSW
YSMUYANNLOSK E OINNOSCH
Write a program TranspositionCipher.java that reads a key from the keyboard and a plaintext from a file
plain.txt, then displays the ciphertext. The plain.txt may contain multiple lines with lower case letters and
spaces. A sample of plain.txt is provided on the com6470 webpage, however your code should be able to handle
other input files. The ciphertext should be displayed on the screen using upper case letters and spaces. A key is a
sequence of lower case letters only, and any letter cannot appear more than once. If there is more than one space
left in the final row, they should be filled in with randomly generated lower case letters before encryption.
i have no idea how to do this, i only started java 5 weeks ago! i would be grateful if someone could help..
11-04-2006, 11:11 AM #2
- Join Date
- Oct 2003
- on a ship
- Thanked 6 Times in 5 Posts
but i would suggest that you look into toUpperCase() and toLowerCase() for changing the letters in the string.
as far as finding spaces and replacing them with a random alpha char