|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthcrypto.cipher.CipherEngine
hcrypto.cipher.BlockCipher
hcrypto.engines.TranspositionEngine
public class TranspositionEngine
Implements a Transposition cipher algorithm for any range of alphabets, including az, AZ, azAZ, azAZ09, printable characters, and all ASCII. A keyword is retrieved from the "TranspositionKey.html">TranspositionKey class and stored in a String instance variable. The keyword consists of a series of positive integers, i.e. "3021".
Encryption involves transposing a plaintext character from a given message with another character from the same plain text message. The basic algorithm for encrypting is:
StringBuffer sb = new StringBuffer(blocksize);
for (int k = 0; k < keyword.length(); k++) {
sb.setCharAt((int)(keyword.charAt(k) - '0'), s.charAt(k));
}
return sb;
Decryption basically involves the same algorithm, only with an inverted keyword (created and retrieved from the TranspositionKey class).
StringBuffer sb = new StringBuffer(blocksize);
for (int k = 0; k < keyword.length(); k++) {
sb.setCharAt((int)(invertedKeyword.charAt(k) - '0'), s.charAt(k));
}
return sb;
Padding and blocksize are handled in the engineEncode(String s) and engineDecode(String s) methods
See also:
TranspositionKey
Alphabet
| Constructor Summary | |
|---|---|
TranspositionEngine()
Creates a TranspositionEngine 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 |
|---|
public TranspositionEngine()
| Method Detail |
|---|
public java.lang.String engineEncode(java.lang.String s)
throws java.lang.Exception
s - the String to be encrypted
java.lang.Exception
public java.lang.String engineDecode(java.lang.String s)
throws java.lang.Exception
s - the String to be decrypted
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||