hcrypto.engines
Class VigenereEngine

java.lang.Object
  |
  +--hcrypto.cipher.CipherEngine
        |
        +--hcrypto.cipher.BlockCipher
              |
              +--hcrypto.engines.VigenereEngine

public class VigenereEngine
extends BlockCipher

VigenereEngine.java 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.

See also:


VigenereKey
Alphabet


Fields inherited from class hcrypto.cipher.BlockCipher
alphabet, blocksize
 
Fields inherited from class hcrypto.cipher.CipherEngine
alphabetRangeOptions
 
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 encoded String for the specified String.
 java.lang.String engineEncode(java.lang.String s)
          Returns an encoded String for the specified String.
protected  void engineInit(HistoricalKey hKey)
          Initializes the VigenereEngine with the specified hKey.
 
Methods inherited from class hcrypto.cipher.BlockCipher
engineDecrypt, engineDecryptFile, engineEncrypt, engineEncryptFile
 
Methods inherited from class hcrypto.cipher.CipherEngine
getAlphabetRangeOptions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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

engineInit

protected void engineInit(HistoricalKey hKey)
                   throws java.lang.Exception
Initializes the VigenereEngine with the specified hKey.
Overrides:
engineInit in class BlockCipher
Parameters:
hKey - a VigenereKey.

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.
Overrides:
engineEncode in class BlockCipher
Parameters:
s - the String to be encrypted

engineDecode

public java.lang.String engineDecode(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.
Overrides:
engineDecode in class BlockCipher
Parameters:
s - the String to be decrypted