Class DigestSpec

java.lang.Object
org.cryptacular.spec.DigestSpec
All Implemented Interfaces:
Spec<org.bouncycastle.crypto.Digest>

public class DigestSpec extends Object implements Spec<org.bouncycastle.crypto.Digest>
Describes a message digest function by name and provides a means to create a new instance of the digest via the newInstance() method.
Author:
Middleware Services
  • Constructor Details

    • DigestSpec

      public DigestSpec(String algName)
      Creates a new instance from the given algorithm name.
      Parameters:
      algName - Digest algorithm name.
    • DigestSpec

      public DigestSpec(String algName, int digestSize)
      Constructor for digests that have variable output size, e.g. SHA3.
      Parameters:
      algName - Digest algorithm name.
      digestSize - Size of resultant digest in bits.
  • Method Details

    • getAlgorithm

      public String getAlgorithm()
      Specified by:
      getAlgorithm in interface Spec<org.bouncycastle.crypto.Digest>
      Returns:
      Cryptographic algorithm name.
    • getSize

      public int getSize()
      Returns:
      Size of digest output in bytes, or -1 if the digest does not support variable size output.
    • newInstance

      public org.bouncycastle.crypto.Digest newInstance()
      Creates a new digest instance.
      Specified by:
      newInstance in interface Spec<org.bouncycastle.crypto.Digest>
      Returns:
      Digest instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object