All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class IS.hi.logir.cryptonite.CaesarKey

java.lang.Object
   |
   +----IS.hi.logir.cryptonite.Key
           |
           +----IS.hi.logir.cryptonite.CaesarKey

public final class CaesarKey
extends Key
implements Serializable, Fingerprintable
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.

Data is encrypted byte-for-byte by adding a constant value to it and taking the 8 lowest order bits.

Author:
Logi Ragnarsson (logir@hi.is)

Variable Index

 o shift

Constructor Index

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

Method Index

 o algorithmName()
Return the name of the algorithm used by this key.
 o calcFingerprint()
Return the key's MD5 fingerprint.
 o createKeys(int, String, String)
Create a pair of public/private keys.
 o createKeys(String, String)
Create a pair of public/private keys.
 o decrypt(Data, Data)
Decrypt the data from source with this key and put the plain data in dest.
 o encrypt(Data, Data)
Encrypt the first sourceLength bytes of source with this key and return an array with the encrypted data.
 o equals(Object)
Return true if the two keys are eqivalent.
 o getSize()
Return the size of the key in bits.
 o matches(Key)
Returns true if this and key are a matched pair of public/private keys.
 o toString()
Return a string representation of this key.

Variables

 o shift
 private byte shift

Constructors

 o CaesarKey
 public CaesarKey(byte shift,
                  String ownerName,
                  String ownerMail)
Create a new Caesar key with the specified shift. It will be marked as belonging to ownerName with e-mail address ownerMail.

Methods

 o createKeys
 public static KeyPair createKeys(String ownerName,
                                  String ownerMail)
Create a pair of public/private keys. They will be marked as belonging to ownerName with e-mail address ownerMail.

 o createKeys
 public static KeyPair createKeys(int notUsed,
                                  String ownerName,
                                  String ownerMail)
Create a pair of public/private keys. They will be marked as belonging to ownerName with e-mail address ownerMail.

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

Overrides:
getSize in class Key
 o calcFingerprint
 protected final Fingerprint calcFingerprint()
Return the key's MD5 fingerprint.

Overrides:
calcFingerprint in class Key
See Also:
MD5State, Fingerprintable
 o algorithmName
 public String algorithmName()
Return the name of the algorithm used by this key.

Overrides:
algorithmName in class Key
 o toString
 public String toString()
Return a string representation of this key.

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

Overrides:
equals in class Object
 o matches
 public final boolean matches(Key key)
Returns true if this and key are a matched pair of public/private keys.

Overrides:
matches in class Key
 o encrypt
 public final void encrypt(Data source,
                           Data dest)
Encrypt the first sourceLength bytes of source with this key and return an array with the encrypted data.

Overrides:
encrypt in class Key
 o decrypt
 public void decrypt(Data source,
                     Data dest)
Decrypt the data from source with this key and put the plain data in dest. The source.buf and dest.buf arrays must be different.

Overrides:
decrypt in class Key

All Packages  Class Hierarchy  This Package  Previous  Next  Index