Class AbstractHashBean

java.lang.Object
org.cryptacular.bean.AbstractHashBean
Direct Known Subclasses:
EncodingHashBean, SimpleHashBean

public abstract class AbstractHashBean extends Object
Abstract base class for all hash beans.
Author:
Middleware Services
  • Constructor Details

    • AbstractHashBean

      public AbstractHashBean()
      Creates a new instance.
    • AbstractHashBean

      public AbstractHashBean(Spec<org.bouncycastle.crypto.Digest> digestSpec, int iterations)
      Creates a new instance by specifying all properties.
      Parameters:
      digestSpec - Digest specification.
      iterations - Number of hash rounds.
  • Method Details

    • getDigestSpec

      public Spec<org.bouncycastle.crypto.Digest> getDigestSpec()
      Returns:
      Digest specification that determines the instance of Digest used to compute the hash.
    • setDigestSpec

      public void setDigestSpec(Spec<org.bouncycastle.crypto.Digest> digestSpec)
      Sets the digest specification that determines the instance of Digest used to compute the hash.
      Parameters:
      digestSpec - Digest algorithm specification.
    • getIterations

      public int getIterations()
      Returns:
      Number of iterations the digest function is applied to the input data.
    • setIterations

      public void setIterations(int iterations)
      Sets the number of iterations the digest function is applied to the input data.
      Parameters:
      iterations - Number of hash rounds. Default value is 1.
    • hashInternal

      protected byte[] hashInternal(Object... data)
      Hashes the given data.
      Parameters:
      data - Data to hash.
      Returns:
      Digest output.
    • compareInternal

      protected boolean compareInternal(byte[] hash, Object... data)
      Compares the hash of the given data against a known hash output.
      Parameters:
      hash - Known hash value. If the length of the array is greater than the length of the digest output, anything beyond the digest length is considered salt data that is hashed after the input data.
      data - Data to hash.
      Returns:
      True if hashed data equals known hash output, false otherwise.