|
||||||||||
| 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.PlayfairEngine
public class PlayfairEngine
Implements the Playfair encryption algorithm. In this algorithm, pairs of individual letters from the range a..z are mapped into pairs of symbols taken from a 2-dimensional square matrix. The letter 'j' is dropped from the ciphertext alphabet. Thus, in this implementation, the ciphertext alphabet consists of the letters a..z, minus the letter 'j'. A keyword is used to vary the distribution of the letters in the matrix.
For example: If the keyword is "keyword", the matrix would look like this:
k e y w o
r d a b c
f g h i l
m n p q s
t u v x z
The following rules are used to perform the mapping:
1. If both letters happen to be in the same row, the letters immediately to the right of each letter are used. The letter to the "right" of the last letter in a row is the first letter in that same row. For example, given the above square, "ey" would be encrypted as "yw".
2. If both letters are in the same column, the letters immediately below each letter are used. The letter "below" a bottom letter is the top letter of the same column. For example, given the above square, "ed" would be encrypted by "dg".
3. If the two letters are in different rows and in different columns, each letter is replaced by the letter in the same row that is also in the column occupied by the other letter. For example, for the above square, "dh" would be encrypted by "ag".
PlayfairKey
Alphabet
| Constructor Summary | |
|---|---|
PlayfairEngine()
Creates a PlayfairEngine and sets the alphabetRangeOptions instance variable to "100000", which translates to the "az" alphabet option only for both plaintext and ciphertext. |
|
| 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 PlayfairEngine()
| 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 | |||||||||