|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthcrypto.cipher.CipherEngine
hcrypto.cipher.BlockCipher
hcrypto.engines.VigenereEngine
public class VigenereEngine
Implements a traditional Vigenere Cipher for the full range of alphabets -- az, AZ, azAZ, azAZ09, printable characters, and all ASCII. The encoding method is based upon the following function: CipherChar = PlainChar + KeyChar The decoding method is based upon the following function: PlainChar = CipherChar - KeyChar A traditional Vigenere assumes that the alphabet is AZ and that the key characters is also in the range AZ. However, for this system the key character may not be in the same range as the cipher of plain character. In that case, the key character must be scaled to fall into the range of the plain or cipher character. For example, if the plain character is a digit, '5', and the key character is the letter 't', then 't' must be scaled to a value between 0 and 9. Since 't' is character 19 in a..z, we scale it to 9 ( = 19 % 10). This allows us to shift '5' by 9 (% 10), giving '4'. On decoding, the key characters 't' will occur above '4'. Again we scale to 't' to 9 and perform subtraction (% 10) to get '5'. A similar kind of scaling occurs for other alphabet ranges. NOTE: Added 12/15/2004. The encode() and decode() methods used by this implementation of VigenereEngine were tested using cryptograms in A. Sinkov, Elementary Cryptanalysis, p59 and p77. They produced identical encryptions to those used in Sinkov.
See also:
VigenereKey
Alphabet
| Constructor Summary | |
|---|---|
VigenereEngine()
Creates a VigenereEngine and sets the alphabetRangeOptions instance variable to "111111", which translates to all six alphabet options. |
|
| Method Summary | |
|---|---|
java.lang.String |
engineDecode(java.lang.String s)
Returns an decoded String for the specified String. |
java.lang.String |
engineEncode(java.lang.String s)
Returns an encoded String for the specified String. |
| Methods inherited from class hcrypto.cipher.CipherEngine |
|---|
getAlphabetRangeOptions |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public VigenereEngine()
| Method Detail |
|---|
public java.lang.String engineEncode(java.lang.String s)
throws java.lang.Exception
s - the String to be encrypted
java.lang.Exception
public java.lang.String engineDecode(java.lang.String s)
throws java.lang.Exception
s - the String to be decrypted
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||