|
||||||||||
| 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.AffineEngine
public class AffineEngine
Implements an Affine cipher algorithm (a special case of a Substitution Cipher that encrypts and decrypts a character based on two Affine functions) for any of three alphabet ranges including az, AZ, az+AZ.
For a good overview of Affine cipher see the discussion on Wikipedia.
The AffineKey is composed of two integers: A_E_Key and B_E_Key which represent "encryption key A" and "encryption key B" respectfully. Two additional keys are created in this class for decrypting: A_D_Key and B_D_Key.
A_D_Key is created by computing the multiplicative inverse (mod 26) of the A_E_Key with a private function.
B_D_Key is created by subtracting the B_E_Key from 26, modulus 26.
B_D_Key = (26 - B_E_Key) % 26 )
engineEncode(String s) performs the following function:
encrypt(x) = ax + b mod 26
engineDecode(String s) performs the following function:
decrypt(y) = inverse of (a) * (y - b) mod 26
See also:
AffineKey
Alphabet
| Constructor Summary | |
|---|---|
AffineEngine()
Creates an AffineEngine and sets the alphabetRangeOptions instance variable to "110000", which translates to the "az+AZ"alphabet option for both the plaintext and ciphertext alphabets. |
|
| 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 AffineEngine()
| 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 | |||||||||