|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthcrypto.cipher.HistoricalKey
plugins.CaesarKey
public class CaesarKey
Represents a key for a Caesar (shift) cipher. The key is entirely represented by an integer, shift, which specifies by how many characters each letter of the plaintext is supposed to be shifted to the right in the alphabet. For example, with a shift of 3, the letter 'A' would become 'D' and the digit '1' would become '4'.
For this implementation of Caesar cipher any of the alphabet ranges can be used and any nonnegative shift value can be specified. If the shift exceeds the range of characters in the alphabet -- e.g., if the shift is 100 and the alphabet is 'a'..'z', then the shift is scaled modulo 26. Negative shift values are rejected, resulting in an exception.
See also:
CaesarEngine
Alphabet
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_KEY_DESCRIPTOR_PROMPT_STRING
A description for a Caesar Key. |
static java.lang.String |
DEFAULT_KEYWORD_STRING
A default key value. |
| Constructor Summary | |
|---|---|
CaesarKey()
|
|
| Method Summary | |
|---|---|
java.lang.String |
getAlgorithm()
Returns the algorithm name "Caesar". |
int |
getShift()
Returns shift value. |
void |
init(java.lang.String keyspec)
Initializes the CaesarKey with the specified keyspec (which takes the form "4/az" or "4/az/AZ" for example). |
void |
init(java.lang.String keyword,
Alphabet alpha1,
Alphabet alpha2)
Initializes the CaesarKey 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 CaesarKey()
| Method Detail |
|---|
public void init(java.lang.String keyspec)
throws java.lang.Exception
init in class HistoricalKeykeySpec - takes the form "integer/alphabet", i.e. "5/az+AZ+09"
which would be mapped into the instance variables shift as an integer with the value of 5,
keyword as a String with the value of "5", and alphabet as a String with the value "az+AZ+09".
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 int getShift()
public java.lang.String getAlgorithm()
getAlgorithm in class HistoricalKey
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||