All Packages Class Hierarchy This Package Previous Next Index
Class is.hi.logir.cryptonite.CaesarKey
java.lang.Object
|
+----is.hi.logir.cryptonite.Cryptonite
|
+----is.hi.logir.cryptonite.K
|
+----is.hi.logir.cryptonite.SymmetricKey
|
+----is.hi.logir.cryptonite.CaesarKey
- public final class CaesarKey
- extends SymmetricKey
- implements CipherKey
The Caesar algorithm is supposedly the one Julius Caesar used by
hand many centuries ago. As you can imagine, this is NOT A STRONG
CIPHER, but included only to show how to write a very simple
Key class for the Cryptonite package. Often, the first assignment given
to cryptography students is to break this cipher.
Data is encrypted byte-by-byte by adding a constant value to it and
taking the 8 lowest order bits.
The CDS for a CaesarKey object is CaesarKey(n)
where
n is a value in the range 0..255.
- Author:
- Logi Ragnarsson
(logir@hi.is)
-
CaesarKey()
- Create a new random Caesar key.
-
CaesarKey(byte)
- Create a new Caesar key with the specified shift.
-
CaesarKey(String)
- Called by
Cryptonite.fromString(String)
.
-
cipherBlockSize()
- The block-size for the Caesar cipher is one byte.
-
decrypt(byte[], int, byte[], int)
- Decrypt
source[i]
and put it dest[j]
.
-
encrypt(byte[], int, byte[], int)
- Encrypt
source[i]
and put it dest[j]
.
-
equals(Object)
- Return true if the two keys are eqivalent.
-
getAlgorithm()
- Return the name of the algorithm used by this key.
-
getSize()
- Return the size of the key in bits.
-
plainBlockSize()
- The block-size for the Caesar cipher is one byte.
-
toString()
- Return a CDS for this key.
CaesarKey
public CaesarKey(byte shift)
- Create a new Caesar key with the specified shift.
CaesarKey
public CaesarKey()
- Create a new random Caesar key.
CaesarKey
public CaesarKey(String shift) throws InvalidCDSException
- Called by
Cryptonite.fromString(String)
.
- Throws: InvalidCDSException
- if the CDS is in some way malformed.
getSize
public int getSize()
- Return the size of the key in bits.
- Overrides:
- getSize in class K
plainBlockSize
public final int plainBlockSize()
- The block-size for the Caesar cipher is one byte.
cipherBlockSize
public final int cipherBlockSize()
- The block-size for the Caesar cipher is one byte.
getAlgorithm
public String getAlgorithm()
- Return the name of the algorithm used by this key.
- Overrides:
- getAlgorithm in class K
equals
public final boolean equals(Object o)
- Return true if the two keys are eqivalent.
- Overrides:
- equals in class Object
toString
public String toString()
- Return a CDS for this key.
- Overrides:
- toString in class Object
encrypt
public final void encrypt(byte source[],
int i,
byte dest[],
int j)
- Encrypt
source[i]
and put it dest[j]
.
decrypt
public final void decrypt(byte source[],
int i,
byte dest[],
int j)
- Decrypt
source[i]
and put it dest[j]
.
All Packages Class Hierarchy This Package Previous Next Index