org.clazzes.optional.sec
Interface Digest

All Known Implementing Classes:
GeneralDigest, SHA1Digest, SHA256Digest

public interface Digest

An interface, which encapsulates secure hash function like SHA-1 or SHA-256.


Method Summary
 Digest cloneState()
           
 int doFinal(byte[] hash, int off)
          Retrieve the hash of all data added so far with update(byte[], int, int).
 java.lang.String getAlgorithmName()
           
 int getByteLength()
          Return the size in bytes of the internal buffer the digest applies it's compression function to.
 int getDigestSize()
           
 void reset()
          Reset the hash in order to reuse this instance.
 void update(byte in)
          update the message digest with a single byte.
 void update(byte[] data, int off, int length)
          Add more data to the hash function.
 

Method Detail

getAlgorithmName

java.lang.String getAlgorithmName()
Returns:
The name of the digest algorithm.

getDigestSize

int getDigestSize()
Returns:
The size of computed hashes.

cloneState

Digest cloneState()
Returns:
A new digest in identical state. This is used, when you want to calculate an intermediate digest value and continue afterward with adding more content.

getByteLength

int getByteLength()
Return the size in bytes of the internal buffer the digest applies it's compression function to.

Returns:
byte length of the digests internal buffer.

reset

void reset()
Reset the hash in order to reuse this instance.


update

void update(byte in)
update the message digest with a single byte.

Parameters:
in - the input byte to be entered.

update

void update(byte[] data,
            int off,
            int length)
Add more data to the hash function.

Parameters:
data - The buffer where the data to add is stored. length bytes starting with off will be written.
off - The offset at which the data is stored.
length - The number of bytes to add.

doFinal

int doFinal(byte[] hash,
            int off)
Retrieve the hash of all data added so far with update(byte[], int, int).

Parameters:
hash - The buffer, where the computed hash will be stored. getDigestSize() bytes starting at off will be written to hash.
off - The offset at which the hash is stored.
Returns:
The number of bytes written, which is equal to getDigestSize().


Copyright © 2010. All Rights Reserved.