hcrypto.engines
Class SubstitutionEngine

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

public class SubstitutionEngine
extends BlockCipher

Implements a keyword-based Substitution cipher algorithm for any range of alphabets, including az, AZ, azAZ, azAZ09, printable characters, all ASCII, and any of the Unicode character sets. A plaintext alphabet is retrieved from the SubstitutionKey class and stored in a character array. A cipher alphabet is created by inserting the characters from the keyword into the first elements of the array, followed by all remaining characters in the particular alphabet.

Encryption involves replacing a plaintext character from a given message with a character from the cipher alphabet with the same index. Decrypting works in the reverse order.

      plainKey = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,......];
      keyword = calm;
      cipherAlphabet = [c,a,l,m,b,d,e,f,g,h,i,j,k,n,o,p,......];
      
      engineEncrypt("cab") == "lca"
      engineDecrypt("lca") == "cab"
 

See also:


SubstitutionKey
Alphabet


Constructor Summary
SubstitutionEngine()
          Creates a SubstitutionEngine 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.
 
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

SubstitutionEngine

public SubstitutionEngine()
Creates a SubstitutionEngine 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 encoded 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