Interface HashBean<T>

Type Parameters:
T - Type of output (e.g. byte[], string) produced by hash bean.
All Known Implementing Classes:
BCryptHashBean, EncodingHashBean, SimpleHashBean

public interface HashBean<T>
Strategy interface to support beans that produce hash outputs in various formats, e.g. raw bytes, hex output, etc.
Author:
Middleware Services
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    compare(T hash, Object... data)
    Compares a known hash value with the hash of the given data.
    hash(Object... data)
    Hashes the given data.
  • Method Details

    • hash

      T hash(Object... data) throws CryptoException, StreamException
      Hashes the given data.
      Parameters:
      data - Data to hash. Callers should expect support for at least the following types: byte[], CharSequence, InputStream, and Resource. Unless otherwise noted, character data is processed in the UTF-8 character set; if another character set is desired, the caller should convert to byte[] and provide the resulting bytes.
      Returns:
      Digest output.
      Throws:
      CryptoException - on hash computation errors.
      StreamException - on stream IO errors.
    • compare

      boolean compare(T hash, Object... data) throws CryptoException, StreamException
      Compares a known hash value with the hash of the given data.
      Parameters:
      hash - Known hash value.
      data - Data to hash.
      Returns:
      True if the hashed data matches the given hash, false otherwise.
      Throws:
      CryptoException - on hash computation errors.
      StreamException - on stream IO errors.