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 26
and decrypt(y) = inverse of (a) * (y - b) mod 26.
This implementation of the Affine cipher is restricted to the alphabet ranges "az", "AZ", and "azAZ".
See also:
AffineCipherSpi
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 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.