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)

Constructor Index

 o CaesarKey()
Create a new random Caesar key.
 o CaesarKey(byte)
Create a new Caesar key with the specified shift.
 o CaesarKey(String)
Called by Cryptonite.fromString(String) .

Method Index

 o cipherBlockSize()
The block-size for the Caesar cipher is one byte.
 o decrypt(byte[], int, byte[], int)
Decrypt source[i] and put it dest[j].
 o encrypt(byte[], int, byte[], int)
Encrypt source[i] and put it dest[j].
 o equals(Object)
Return true if the two keys are eqivalent.
 o getAlgorithm()
Return the name of the algorithm used by this key.
 o getSize()
Return the size of the key in bits.
 o plainBlockSize()
The block-size for the Caesar cipher is one byte.
 o toString()
Return a CDS for this key.

Constructors

 o CaesarKey
 public CaesarKey(byte shift)
Create a new Caesar key with the specified shift.

 o CaesarKey
 public CaesarKey()
Create a new random Caesar key.

 o CaesarKey
 public CaesarKey(String shift) throws InvalidCDSException
Called by Cryptonite.fromString(String) .

Throws: InvalidCDSException
if the CDS is in some way malformed.

Methods

 o getSize
 public int getSize()
Return the size of the key in bits.

Overrides:
getSize in class K
 o plainBlockSize
 public final int plainBlockSize()
The block-size for the Caesar cipher is one byte.

 o cipherBlockSize
 public final int cipherBlockSize()
The block-size for the Caesar cipher is one byte.

 o getAlgorithm
 public String getAlgorithm()
Return the name of the algorithm used by this key.

Overrides:
getAlgorithm in class K
 o equals
 public final boolean equals(Object o)
Return true if the two keys are eqivalent.

Overrides:
equals in class Object
 o toString
 public String toString()
Return a CDS for this key.

Overrides:
toString in class Object
 o encrypt
 public final void encrypt(byte source[],
                           int i,
                           byte dest[],
                           int j)
Encrypt source[i] and put it dest[j].

 o 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