| | |
WTF!!! Vigenère Ciphering
![]() |
•
•
Join Date: Nov 2006
Posts: 7
Reputation:
Solved Threads: 0
Vigenère Ciphering
You are to develop a program to implement Vigenère ciphering to encrypt and decrypt text
information. A description of Vigenère ciphering can be found at:
http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher.
To illustrate encryption, a table of characters shown below can be used, termed a tabula recta,
Vigenère square, or Vigenère table. It consists of the alphabet written out 26 times in different
rows, each alphabet shifted cyclically to the left compared to the previous alphabet,
corresponding to the 26 possible Caesar ciphers. For each letter in the plain text, a letter from a
repeated keyword is used to define which row in the table is used to encrypt the character.
For example, suppose that the plaintext to be encrypted is (note that spaces an non alphabetic
characters are not allowed):
ATTACKATDAWN
The person sending the message chooses an encryption keyword which is repeated until it
matches the length of the plaintext, for example, consider the keyword "LEMON":
LEMONLEMONLE
The first letter of the plaintext, A, is encrypted using the alphabet in row L, which is the first
letter of the key. This is done by looking at the letter in row L and column A of the Vigenère
square, namely L. Similarly, for the second letter of the plaintext, the second letter of the key is
used; the letter at row E and column T is X. The rest of the plaintext is enciphered in a similar
fashion:
Plaintext: ATTACKATDAWN
Key: LEMONLEMONLE
Ciphertext LXFOPVEFRNHR
Decryption is performed by finding the position of the ciphertext letter in a row of the table
(using the character from the keyword to select the row), and then taking the label of the column
in which it appears as the plaintext. For example, in row L, the ciphertext L appears in column A,
which taken as the first plaintext letter. The second letter is decrypted by looking up X in row E
of the table; it appears in column T, which is taken as the plaintext letter.
You are to develop a program to implement Vigenère ciphering to encrypt and decrypt text
information. A description of Vigenère ciphering can be found at:
http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher.
To illustrate encryption, a table of characters shown below can be used, termed a tabula recta,
Vigenère square, or Vigenère table. It consists of the alphabet written out 26 times in different
rows, each alphabet shifted cyclically to the left compared to the previous alphabet,
corresponding to the 26 possible Caesar ciphers. For each letter in the plain text, a letter from a
repeated keyword is used to define which row in the table is used to encrypt the character.
For example, suppose that the plaintext to be encrypted is (note that spaces an non alphabetic
characters are not allowed):
ATTACKATDAWN
The person sending the message chooses an encryption keyword which is repeated until it
matches the length of the plaintext, for example, consider the keyword "LEMON":
LEMONLEMONLE
The first letter of the plaintext, A, is encrypted using the alphabet in row L, which is the first
letter of the key. This is done by looking at the letter in row L and column A of the Vigenère
square, namely L. Similarly, for the second letter of the plaintext, the second letter of the key is
used; the letter at row E and column T is X. The rest of the plaintext is enciphered in a similar
fashion:
Plaintext: ATTACKATDAWN
Key: LEMONLEMONLE
Ciphertext LXFOPVEFRNHR
Decryption is performed by finding the position of the ciphertext letter in a row of the table
(using the character from the keyword to select the row), and then taking the label of the column
in which it appears as the plaintext. For example, in row L, the ciphertext L appears in column A,
which taken as the first plaintext letter. The second letter is decrypted by looking up X in row E
of the table; it appears in column T, which is taken as the plaintext letter.
0
#3 24 Days Ago
Well I would use a double matrix:
Then for mapping the letters with the numbers in a quick way:
The key is the letter and the value is the number. So when you have a letter, get the number from the map and you the index to use for the array
Java Syntax (Toggle Plain Text)
String [][] ARRAY = { {"A", "B", ...}, {"B", "C", ...}, {"C", "D", ...}, .... }
Then for mapping the letters with the numbers in a quick way:
Java Syntax (Toggle Plain Text)
HashMap map = new HashMap(26); map.put("A",0); map.put("B",1); ...
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
- Vigenère de-cipher (C)
- The True Stories Behind 5 Famous WTF Images (Geeks' Lounge)
- IRQL_NOT_LESS_OR_EQUAL (Windows NT / 2000 / XP)
- Md5 - Wtf? (Computer Science)
- Formatting (Windows NT / 2000 / XP)
- compiling error wtf!?!? (C)
- Something wrong with windows XP (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: how to output the result in jframe
- Next Thread: java applets
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary blackberry block bluetooth character chat class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing test textfields threads time title tree tutorial-sample ubuntu update windows working






