944,213 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 732
  • Java RSS
Nov 2nd, 2009
-1

WTF!!! Vigenère Ciphering

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bmanoman is offline Offline
7 posts
since Nov 2006
Nov 2nd, 2009
0

hm...

im not even sure how to start...
i put it as a matrix right?
and change letters to numbers?
i know its worded more complicated than it probably actually is though
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bmanoman is offline Offline
7 posts
since Nov 2006
Nov 3rd, 2009
0
Re: WTF!!! Vigenère Ciphering
Well I would use a double matrix:
Java Syntax (Toggle Plain Text)
  1. String [][] ARRAY = {
  2. {"A", "B", ...},
  3. {"B", "C", ...},
  4. {"C", "D", ...},
  5. ....
  6. }

Then for mapping the letters with the numbers in a quick way:
Java Syntax (Toggle Plain Text)
  1. HashMap map = new HashMap(26);
  2. map.put("A",0);
  3. map.put("B",1);
  4. ...
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
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 447
Nearly a Senior Poster
javaAddict is offline Offline
3,260 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: how to output the result in jframe
Next Thread in Java Forum Timeline: java applets





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC