|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthcrypto.cipher.HistoricalKey
hcrypto.engines.AffineKey
public class AffineKey
Represents a key for an Affine cipher. The key is entirely represented by two integers, a and b, which serve as variables in the Affine functions: encrypt(x) = ax + b mod N and decrypt(y) = inverse_of(a) * (y - b) mod N where N = size of the alphabet.
For a good overview of Affine cipher see the discussion on Wikipedia.
Example key and argument: 3,3/az+AZ yourTEXThere
NOTE: The Affine algorithm does not accept digits (0..9) as part of the alphabet.
This implementation of the Affine cipher is restricted to condition that the plaintext alphabet and ciphertext alphabet must have the same size.
See also:
AffineEngine
Alphabet
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_KEY_DESCRIPTOR_PROMPT_STRING
A description for an Affine Key. |
static java.lang.String |
DEFAULT_KEYWORD_STRING
Default key values. |
| Constructor Summary | |
|---|---|
AffineKey()
|
|
| Method Summary | |
|---|---|
java.lang.String |
getAlgorithm()
Returns the algorithm name "Affine". |
int |
getKeyA()
Returns the keyA value for the Affine function. |
int |
getKeyB()
Returns the keyB value for the Affine function. |
void |
init(java.lang.String keyspec)
Creates an AffineKey with the specified keyspec. |
void |
init(java.lang.String keyword,
Alphabet alpha1,
Alphabet alpha2)
Initializes the AffineKey given a keyword and one or more alphabets. |
| Methods inherited from class hcrypto.cipher.HistoricalKey |
|---|
getAlphabet, getBlocksize, getCipherKey, getCTAlphabet, getInstance, getKeyDescriptorPrompt, getKeyword, getPlainKey, initKey, initKey, invertKey, printAlphabets, removeDuplicateChars |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DEFAULT_KEY_DESCRIPTOR_PROMPT_STRING
public static final java.lang.String DEFAULT_KEYWORD_STRING
| Constructor Detail |
|---|
public AffineKey()
| Method Detail |
|---|
public void init(java.lang.String keyspec)
throws java.lang.Exception
init in class HistoricalKeykeyspec - takes the form "integer,integer/alphabet", i.e.
"5,21/az" for example, which would be mapped into the instance variables
keyword as a String with the value "5,21", and alphabet as
a String with the value "az".
java.lang.Exception
public void init(java.lang.String keyword,
Alphabet alpha1,
Alphabet alpha2)
throws java.lang.Exception
init in class HistoricalKeykeyword - -- a string version of the keywordalpha1, - alpha2 -- Alphabets for plain/ciphertext respectively. May
be identical.
java.lang.Exceptionpublic java.lang.String getAlgorithm()
getAlgorithm in class HistoricalKeypublic int getKeyA()
public int getKeyB()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||