hcrypto.cipher
Class CipherEngine

java.lang.Object
  |
  +--hcrypto.cipher.CipherEngine
Direct Known Subclasses:
BlockCipher

public abstract class CipherEngine
extends java.lang.Object

The CipherEngine class defines the interface for the Cipher class. All of the methods in this class must be implemented by a provider who wishes to provide an implementation of a particular cipher algorithm.

The Cipher class encapsulates an instance of this class. To create a Cipher instance, an application would use the Cipher.getInstance(String algorithm) factory method, where algorithm provides the name of the cipher algorithm -- e.g., "Caesar", * "Playfair", and so on.

For example, here's sample code for instantiating and using a Caesar cipher:

      Cipher cipher = Cipher.getInstance("Caesar");
      HistoricalKey key = HistoricalKey.getInstance("Caesar", cipher.getProvider());
      key.init("55/printable");
      cipher.init(key);
      String c1encrypt = cipher.encrypt(secret);
 
The Cipher.getInstance() method searches the provider list for an implementation of Caesar cipher and will throw a "No such algorithm" exception if none is found. Details on creating an algorithm-dependent key for the cipher are described in the documentation of HistoricalKey class.

See also:


Cipher
HistoricalKey


Field Summary
protected  java.lang.String alphabetRangeOptions
          A string of 0s and 1s that describes the options for possible alphabet ranges.
 
Constructor Summary
CipherEngine()
           
 
Method Summary
protected abstract  java.lang.String engineDecrypt(java.lang.String s)
          engineDecrypt() encrypts its String parameter returning the encrypted string.
protected abstract  void engineDecryptFile(java.lang.String inFile, java.lang.String outFile)
          engineDecryptFile() decrypts a ciphertext input file into an output file.
protected abstract  void engineDecryptFile(java.lang.String inFile, java.lang.String outFile, java.lang.String encoding)
          engineDecryptFile() decrypts a ciphertext input file into an output file.
protected abstract  java.lang.String engineEncrypt(java.lang.String s)
          engineEncrypt() encrypts its String parameter returning the encrypted string.
protected abstract  void engineEncryptFile(java.lang.String inFile, java.lang.String outFile)
          engineEncryptFile() encrypts a plaintext input file into an output file.
protected abstract  void engineEncryptFile(java.lang.String inFile, java.lang.String outFile, java.lang.String encoding)
          engineEncryptFile() encrypts a plaintext input file into an output file.
protected abstract  void engineInit(HistoricalKey key)
          engineInit() initializes the particular encrypting engine based on a key of the appropriate type.
 java.lang.String getAlphabetRangeOptions()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alphabetRangeOptions

protected java.lang.String alphabetRangeOptions
A string of 0s and 1s that describes the options for possible alphabet ranges. Currently there are six RANGE options (see above) and they are to be encoded in the order shown above so that RANGE_az, if that is an option for a particular alphabet, would be encoded by a '1' in the first position of the string. For example, a rangeOptions string of "111100" would allow the cipher to have any of the ranges RANGE_az, RANGE_AZ, RANGE_azAZ or RANGE_azAZ09, but not RANGE_printable or RANGE_ascii. This variable should be set in the cipher constructor.
Constructor Detail

CipherEngine

public CipherEngine()
Method Detail

engineInit

protected abstract void engineInit(HistoricalKey key)
                            throws java.lang.Exception
engineInit() initializes the particular encrypting engine based on a key of the appropriate type. This method is implemented in algorithm-specific ways in the subclass.
Parameters:
key, - an instance of a HistoricalKey

engineEncrypt

protected abstract java.lang.String engineEncrypt(java.lang.String s)
                                           throws java.lang.Exception
engineEncrypt() encrypts its String parameter returning the encrypted string. When implemented, this method should call an engineEncode(String):String method that is implemented in the class that implements the specific cipher algorithm.
Parameters:
s, - a String to be encrypted

engineDecrypt

protected abstract java.lang.String engineDecrypt(java.lang.String s)
                                           throws java.lang.Exception
engineDecrypt() encrypts its String parameter returning the encrypted string. When implemented, this method should call an engineDecode(String):String method that is implemented in the class that implements the specific cipher algorithm.
Parameters:
s, - a String to be encrypted

engineEncryptFile

protected abstract void engineEncryptFile(java.lang.String inFile,
                                          java.lang.String outFile)
                                   throws java.lang.Exception
engineEncryptFile() encrypts a plaintext input file into an output file.
Parameters:
inFile, - the name of the input plaintext file.
outFile, - the name of the output encrypted file.

engineEncryptFile

protected abstract void engineEncryptFile(java.lang.String inFile,
                                          java.lang.String outFile,
                                          java.lang.String encoding)
                                   throws java.lang.Exception
engineEncryptFile() encrypts a plaintext input file into an output file.
Parameters:
inFile, - the name of the input plaintext file.
outFile, - the name of the output encrypted file.
encoding, - the name of the encoding scheme -- "ISO8859" or "ISO-2022-JP"

engineDecryptFile

protected abstract void engineDecryptFile(java.lang.String inFile,
                                          java.lang.String outFile)
                                   throws java.lang.Exception
engineDecryptFile() decrypts a ciphertext input file into an output file.
Parameters:
inFile, - the name of the input ciphertext file.
outFile, - the name of the output plaintext file.

engineDecryptFile

protected abstract void engineDecryptFile(java.lang.String inFile,
                                          java.lang.String outFile,
                                          java.lang.String encoding)
                                   throws java.lang.Exception
engineDecryptFile() decrypts a ciphertext input file into an output file.
Parameters:
inFile, - the name of the input ciphertext file.
outFile, - the name of the output plaintext file.
encoding, - the name of the encoding scheme -- "ISO8859" or "ISO-2022-JP"

getAlphabetRangeOptions

public java.lang.String getAlphabetRangeOptions()