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)
-
shift
-
-
CaesarKey(byte, String, String)
- Create a new Caesar key with the specified shift.
-
algorithmName()
- Return the name of the algorithm used by this key.
-
calcFingerprint()
- Return the key's MD5 fingerprint.
-
createKeys(int, String, String)
- Create a pair of public/private keys.
-
createKeys(String, String)
- Create a pair of public/private keys.
-
decrypt(Data, Data)
- Decrypt the data from source with this key and put the plain data
in dest.
-
encrypt(Data, Data)
- Encrypt the first sourceLength bytes of source with
this key and return an array with the encrypted data.
-
equals(Object)
- Return true if the two keys are eqivalent.
-
getSize()
- Return the size of the key in bits.
-
matches(Key)
-
Returns true if this and key are a matched pair
of public/private keys.
-
toString()
- Return a string representation of this key.
shift
private byte shift
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.
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.
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.
getSize
public int getSize()
- Return the size of the key in bits.
- Overrides:
- getSize in class Key
calcFingerprint
protected final Fingerprint calcFingerprint()
- Return the key's MD5 fingerprint.
- Overrides:
- calcFingerprint in class Key
- See Also:
- MD5State, Fingerprintable
algorithmName
public String algorithmName()
- Return the name of the algorithm used by this key.
- Overrides:
- algorithmName in class Key
toString
public String toString()
- Return a string representation of this key.
- Overrides:
- toString in class Key
equals
public final boolean equals(Object o)
- Return true if the two keys are eqivalent.
- Overrides:
- equals in class Object
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
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
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