hcrypto.engines
Class AffineKey
java.lang.Object
|
+--hcrypto.cipher.HistoricalKey
|
+--hcrypto.engines.AffineKey
- public class AffineKey
- extends HistoricalKey
This class 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.
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
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. |
Methods inherited from class hcrypto.cipher.HistoricalKey |
getAlphabet, getBlocksize, getCiphAlphabet, getCTAlphabet, getInstance, getKeyDescriptorPrompt, getKeyword, getPlainAlphabet, initAlphabets, initKey, printAlphabets, removeDuplicateChars |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_KEY_DESCRIPTOR_PROMPT_STRING
public static final java.lang.String DEFAULT_KEY_DESCRIPTOR_PROMPT_STRING
- A description for an Affine Key.
DEFAULT_KEYWORD_STRING
public static final java.lang.String DEFAULT_KEYWORD_STRING
- Default key values.
AffineKey
public AffineKey()
init
public void init(java.lang.String keyspec)
throws java.lang.Exception
- Creates an AffineKey with the specified keyspec.
- Overrides:
init
in class HistoricalKey
- Parameters:
keyspec
- 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".
getAlgorithm
public java.lang.String getAlgorithm()
- Returns the algorithm name "Affine".
- Overrides:
getAlgorithm
in class HistoricalKey
getKeyA
public int getKeyA()
- Returns the keyA value for the Affine function.
getKeyB
public int getKeyB()
- Returns the keyB value for the Affine function.