package aalg.crypto;

/**
 * Function that maps arbitrary length input to constant length output.
 * @author Ing. Petr Ležák
 */
public interface IHashFunction {

	/**
	 * Initializes the hash calculation.
	 */
	public void initialize();
	
	/**
	 * Adds more data of the message.
	 * @param data data to add
	 * @param offset index of the first byte
	 * @param size number of bytes to add
	 */
	public void update (final byte[] data, final int offset, final int size);
	
	/**
	 * Finish calculation of the hash.
	 * @return hash of the message
	 */
	public byte[] finish();
	
	/**
	 * Returns number of bytes of the output hash.
	 * @return number of hash bytes
	 */
	public int getOutputByteCount();
	
	/**
	 * Calculates hash of the message.
	 * Same as:
	 *   initialize();
	 *   update (message, 0, message.length);
	 *   return finish();
	 * 
	 * @param message message to hash
	 * @return hash
	 */
	public byte[] calculateHash (final byte[] message);
}
