hcrypto.engines
Class PlayfairEngine
java.lang.Object
|
+--hcrypto.cipher.CipherEngine
|
+--hcrypto.cipher.BlockCipher
|
+--hcrypto.engines.PlayfairEngine
- public class PlayfairEngine
- extends BlockCipher
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:
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:
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: 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
TranspositionKey
Alphabet
Constructor Summary |
PlayfairEngine()
Creates a PlayfairEngine and sets the alphabetRangeOptions instance variable
to "100000", which translates to the "az" alphabet option only. |
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. |
protected void |
engineInit(HistoricalKey hKey)
Initializes the PlayfairEngine with the specified hKey. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PlayfairEngine
public PlayfairEngine()
- Creates a PlayfairEngine and sets the alphabetRangeOptions instance variable
to "100000", which translates to the "az" alphabet option only.
engineInit
protected void engineInit(HistoricalKey hKey)
throws java.lang.Exception
- Initializes the PlayfairEngine with the specified hKey.
- Overrides:
engineInit
in class BlockCipher
- Parameters:
hKey
- a PlayfairKey.
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.
- Overrides:
engineEncode
in class BlockCipher
- Parameters:
s
- the String to be encrypted
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.
- Overrides:
engineDecode
in class BlockCipher
- Parameters:
s
- the String to be decrypted