/*
 * @(#)Hash.java
 *
 * Copyright (c) 2002-2003 JSCAPE
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JSCAPE. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JSCAPE.
 */

package com.jscape.crypto;

/**
 * A hash algorithm.
 *
 * @author Alex Usun
 */
public interface Hash {

    /**
     * Returns resulting hash length in bytes.
     *
     * @return resulting hash length in bytes
     */
    int getLength();

    /**
     * Resets algorithm state.
     */
    Hash reset();

    /**
     * Updates algorithm with new data.
     *
     * @param data new data
     */
    Hash update(byte data);

    /**
     * Updates algorithm with new data.
     *
     * @param data new data
     */
    Hash update(byte[] data);

    /**
     * Updates algorithm with new data.
     *
     * @param data   new data
     * @param offset data offset
     * @param length data length
     */
    Hash update(byte[] data, int offset, int length);

    /**
     * Computes resulting hash.
     *
     * @return resulting hash
     */
    byte[] compute();

    /**
     * Computes resulting hash.
     *
     * @param data new data
     *
     * @return resulting hash
     */
    byte[] compute(byte[] data);

    /**
     * Computes resulting hash.
     *
     * @param data   new data
     * @param offset data offset
     * @param length data length
     *
     * @return resulting hash
     */
    byte[] compute(byte[] data, int offset, int length);

}
