hcrypto.engines
Class VigenereEngine

java.lang.Object
  extended by hcrypto.cipher.CipherEngine
      extended by hcrypto.cipher.BlockCipher
          extended by hcrypto.engines.VigenereEngine

public class VigenereEngine
extends BlockCipher

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

VigenereEngine

public VigenereEngine()
Creates a VigenereEngine and sets the alphabetRangeOptions instance variable to "111111", which translates to all six alphabet options.

Method Detail

engineEncode

public java.lang.String engineEncode(java.lang.String s)
                              throws java.lang.Exception
Returns an encoded String for the specified String. Characters which are not part of the chosen alphabet set are ignored.

Parameters:
s - the String to be encrypted
Throws:
java.lang.Exception

engineDecode

public java.lang.String engineDecode(java.lang.String s)
                              throws java.lang.Exception
Returns an decoded String for the specified String. Characters which are not part of the chosen alphabet set are ignored.

Parameters:
s - the String to be decrypted
Throws:
java.lang.Exception