# Class ConcurrentMessageDigest

java.lang.Object
org.apache.tomcat.util.security.ConcurrentMessageDigest

public class ConcurrentMessageDigest extends Object
A thread safe wrapper around `MessageDigest` that does not make use of ThreadLocal and - broadly - only creates enough MessageDigest objects to satisfy the concurrency requirements.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static byte[]`
  `digest(String algorithm, byte[]... input)`
  Computes the digest of the given input byte arrays using the specified algorithm.
  `static byte[]`
  `digest(String algorithm, int iterations, byte[]... input)`
  Computes the digest of the given input byte arrays using the specified algorithm and number of iterations.
  `static byte[]`
  `digestMD5(byte[]... input)`
  Computes the MD5 digest of the given input byte arrays.
  `static byte[]`
  `digestSHA1(byte[]... input)`
  Computes the SHA-1 digest of the given input byte arrays.
  `static byte[]`
  `digestSHA256(byte[]... input)`
  Computes the SHA-256 digest of the given input byte arrays.
  `static void`
  `init(String algorithm)`
  Ensures that `digest(String, byte[][])` will support the specified algorithm.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### digestMD5

    public static byte[] digestMD5(byte[]... input)
    Computes the MD5 digest of the given input byte arrays.
    Parameters:
      `input` - the byte arrays to digest
    Returns:
      the MD5 digest

  - ### digestSHA1

    public static byte[] digestSHA1(byte[]... input)
    Computes the SHA-1 digest of the given input byte arrays.
    Parameters:
      `input` - the byte arrays to digest
    Returns:
      the SHA-1 digest

  - ### digestSHA256

    public static byte[] digestSHA256(byte[]... input)
    Computes the SHA-256 digest of the given input byte arrays.
    Parameters:
      `input` - the byte arrays to digest
    Returns:
      the SHA-256 digest

  - ### digest

    public static byte[] digest(String algorithm, byte[]... input)
    Computes the digest of the given input byte arrays using the specified algorithm.
    Parameters:
      `algorithm` - the message digest algorithm name
      `input` - the byte arrays to digest
    Returns:
      the digest

  - ### digest

    public static byte[] digest(String algorithm, int iterations, byte[]... input)
    Computes the digest of the given input byte arrays using the specified algorithm and number of iterations. Multiple iterations are performed by re-digesting the result of the previous iteration.
    Parameters:
      `algorithm` - the message digest algorithm name
      `iterations` - the number of times to apply the digest
      `input` - the byte arrays to digest
    Returns:
      the digest

  - ### init

    public static void init(String algorithm) throws NoSuchAlgorithmException
    Ensures that `digest(String, byte[][])` will support the specified algorithm. This method must be called and return successfully before using `digest(String, byte[][])`.
    Parameters:
      `algorithm` - The message digest algorithm to be supported
    Throws:
      `NoSuchAlgorithmException` - If the algorithm is not supported by the JVM