Package totalcross.crypto.digest
Class Digest
- java.lang.Object
-
- totalcross.crypto.digest.Digest
-
- Direct Known Subclasses:
MD5Digest,SHA1Digest,SHA256Digest
public abstract class Digest extends java.lang.ObjectThis class provides the functionality of a message digest algorithm.
-
-
Field Summary
Fields Modifier and Type Field Description protected ByteArrayStreaminput
-
Constructor Summary
Constructors Constructor Description Digest()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.StringgetAlgorithm()Returns the name of the algorithm.abstract intgetBlockLength()Returns the block length.byte[]getDigest()Finalizes the message digest operation by processing all the accumulated input data and returning the result in a new buffer.abstract intgetDigestLength()Returns the message digest length.protected abstract byte[]process(byte[] data)voidreset()Initializes this message digest.java.lang.StringtoString()Returns the name of the algorithm.voidupdate(byte[] data)Updates the input data that will be processed by this message digest algorithm.voidupdate(byte[] data, int start, int count)Updates the input data that will be processed by this message digest algorithm.voidupdate(int data)Updates the input data that will be processed by this message digest algorithm.
-
-
-
Field Detail
-
input
protected ByteArrayStream input
-
-
Method Detail
-
toString
public java.lang.String toString()
Returns the name of the algorithm.- Overrides:
toStringin classjava.lang.Object- Returns:
- The name of the algorithm whose class heirs from Digest.
-
getAlgorithm
public abstract java.lang.String getAlgorithm()
Returns the name of the algorithm.- Returns:
- The name of the algorithm whose class heirs from Digest.
-
getBlockLength
public abstract int getBlockLength()
Returns the block length.- Returns:
- The block length (in bytes).
-
getDigestLength
public abstract int getDigestLength()
Returns the message digest length.- Returns:
- The message digest length (in bytes).
-
reset
public final void reset()
Initializes this message digest. Calling this method will also reset the input data buffer.
-
update
public final void update(int data)
Updates the input data that will be processed by this message digest algorithm. The data will be accumulated in an input buffer to be processed whengetDigest()is finally called.- Parameters:
data- The input data.
-
update
public final void update(byte[] data)
Updates the input data that will be processed by this message digest algorithm. The data will be accumulated in an input buffer to be processed whengetDigest()is finally called.- Parameters:
data- The input data.
-
update
public final void update(byte[] data, int start, int count)Updates the input data that will be processed by this message digest algorithm. The data will be accumulated in an input buffer to be processed whengetDigest()is finally called.- Parameters:
data- The input data.start- The offset indatawhere the data starts.count- The input length.
-
getDigest
public final byte[] getDigest()
Finalizes the message digest operation by processing all the accumulated input data and returning the result in a new buffer.- Returns:
- The operation result in a new buffer.
-
process
protected abstract byte[] process(byte[] data)
-
-