hcrypto.engines
Class RailFenceEngine
java.lang.Object
|
+--hcrypto.cipher.CipherEngine
|
+--hcrypto.cipher.BlockCipher
|
+--hcrypto.engines.RailFenceEngine
- public class RailFenceEngine
- extends BlockCipher
Constructor Summary |
RailFenceEngine()
Creates a RailFenceEngine and sets the alphabetRangeOptions instance variable
to "111111", which translates to all six alphabet options for both the plaintext
and ciphertext alphabets. |
Method Summary |
java.lang.String |
addPadd(java.lang.String plain)
AddPadd()
This method receives a the plaintext string, with
spaces removed from the engineEncode method. |
java.lang.String |
engineDecode(java.lang.String secret)
DECODE
This method takes ciphertext and places it
into a 2 dimensional array, character by
charcter. |
protected java.lang.String |
engineDecrypt(java.lang.String str)
This method decrypts a String, returning a String. |
java.lang.String |
engineEncode(java.lang.String plain)
This abstract method must be implemented in the subclass to perform
basic encrypting step for a given cipher algorithm. |
protected java.lang.String |
engineEncrypt(java.lang.String str)
This method encrypts a String, returning a String. |
protected void |
engineInit(HistoricalKey hKey)
This abstract method must be implemented in the subclass to perform
initializations required by a given cipher algorithm. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RailFenceEngine
public RailFenceEngine()
- Creates a RailFenceEngine and sets the alphabetRangeOptions instance variable
to "111111", which translates to all six alphabet options for both the plaintext
and ciphertext alphabets.
engineInit
protected void engineInit(HistoricalKey hKey)
throws java.lang.Exception
- Description copied from class:
BlockCipher
- This abstract method must be implemented in the subclass to perform
initializations required by a given cipher algorithm. Its parameter
provides algorithm-specific information that is used to encrypt and
decrypt. The key also provides a reference to the
Alphabet that defines which plaintext
characters are to be encrypted.
- Overrides:
engineInit
in class BlockCipher
- Following copied from class:
hcrypto.cipher.BlockCipher
- Parameters:
key
- an instance of a HistoricalKey subclass appropriate to
the particular cipher algorithm
engineEncrypt
protected java.lang.String engineEncrypt(java.lang.String str)
throws java.lang.Exception
- Description copied from class:
BlockCipher
- This method encrypts a String, returning a String. It invokes
the abstract method encode(String) which is implemented
in an algorithm-specific way in the subclass.
- Overrides:
engineEncrypt
in class BlockCipher
- Following copied from class:
hcrypto.cipher.BlockCipher
- Parameters:
s
- the String to be encrypted
engineDecrypt
protected java.lang.String engineDecrypt(java.lang.String str)
throws java.lang.Exception
- Description copied from class:
BlockCipher
- This method decrypts a String, returning a String. It invokes
the abstract method decode(String) which is implemented
in an algorithm-specific way in the subclass.
- Overrides:
engineDecrypt
in class BlockCipher
- Following copied from class:
hcrypto.cipher.BlockCipher
- Parameters:
s
- the String to be encrypted
addPadd
public java.lang.String addPadd(java.lang.String plain)
- AddPadd()
This method receives a the plaintext string, with
spaces removed from the engineEncode method.
It adds padding letters. The amount of padding is
determined by the key and the length of the message,
using the mod function. If the rows of the railfence
are even then another column of padding is
added. If the rows are not even then enough
letter of padding are added to complete the
uneven rows. The padding letter is dertemined by
the amount of padding needed. eg. 2 letter of
padding would by b, and 3, c, etc. The padding
letters are added appended to the end of the string
and the string is then returned to the engineEncode
method to be encrypted.
engineEncode
public java.lang.String engineEncode(java.lang.String plain)
throws java.lang.Exception
- Description copied from class:
BlockCipher
- This abstract method must be implemented in the subclass to perform
basic encrypting step for a given cipher algorithm.
- Overrides:
engineEncode
in class BlockCipher
engineDecode
public java.lang.String engineDecode(java.lang.String secret)
- DECODE
This method takes ciphertext and places it
into a 2 dimensional array, character by
charcter. The text is then read column by
column into a String. The end of the String
contains n number of padding letters that
are removed. The resulting String is returned
as the decoded text. Note that spaces have
been removed and not replaced.
- Overrides:
engineDecode
in class BlockCipher