HmacUtils (Apache Commons Codec 1.22.1 API)
Description: declaration: package: org.apache.commons.codec.digest, class: HmacUtils

Package org.apache.commons.codec.digest

# Class HmacUtils

java.lang.Object
org.apache.commons.codec.digest.HmacUtils

public final class HmacUtils extends Object
Simplifies common `Mac` tasks. This class is immutable and thread-safe. However the Mac may not be.

Note: Not all JCE implementations support all algorithms. If not supported, an IllegalArgumentException is thrown.

Sample usage:

     import static HmacAlgorithms.*;
     byte[] key = {1,2,3,4}; // don't use this actual key!
     String valueToDigest = "The quick brown fox jumps over the lazy dog";
     byte[] hmac = new HmacUtils(HMAC_SHA_224, key).hmac(valueToDigest);
     // Mac reuse
     HmacUtils hm1 = new HmacUtils("HmacAlgoName", key); // use a valid name here!
     String hexPom = hm1.hmacHex(new File("pom.xml"));
     String hexNot = hm1.hmacHex(new File("NOTICE.txt"));

Since:
  1.10

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HmacUtils()`
  Deprecated.
  Since 1.11; only useful to preserve binary compatibility.
  `HmacUtils(String algorithm, byte[] key)`
  Creates an instance using the provided algorithm type.
  `HmacUtils(String algorithm, String key)`
  Creates an instance using the provided algorithm type.
  `HmacUtils(HmacAlgorithms algorithm, byte[] key)`
  Creates an instance using the provided algorithm type.
  `HmacUtils(HmacAlgorithms algorithm, String key)`
  Creates an instance using the provided algorithm type.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Mac`
  `getHmacMd5(byte[] key)`
  Deprecated.
  (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_MD5, byte[])`.
  `static Mac`
  `getHmacSha1(byte[] key)`
  Deprecated.
  (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_1, byte[])`.
  `static Mac`
  `getHmacSha256(byte[] key)`
  Deprecated.
  (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_256, byte[])`.
  `static Mac`
  `getHmacSha384(byte[] key)`
  Deprecated.
  (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_384, byte[])`.
  `static Mac`
  `getHmacSha512(byte[] key)`
  Deprecated.
  (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_512, byte[])`.
  `static Mac`
  `getInitializedMac(String algorithm, byte[] key)`
  Returns an initialized `Mac` for the given `algorithm`.
  `static Mac`
  `getInitializedMac(HmacAlgorithms algorithm, byte[] key)`
  Returns an initialized `Mac` for the given `algorithm`.
  `byte[]`
  `hmac(byte[] valueToDigest)`
  Returns the digest for the input data.
  `byte[]`
  `hmac(File valueToDigest)`
  Returns the digest for the file.
  `byte[]`
  `hmac(InputStream valueToDigest)`
  Returns the digest for the stream.
  `byte[]`
  `hmac(String valueToDigest)`
  Returns the digest for the input data.
  `byte[]`
  `hmac(ByteBuffer valueToDigest)`
  Returns the digest for the input data.
  `byte[]`
  `hmac(Path valueToDigest)`
  Returns the digest for the file.
  `String`
  `hmacHex(byte[] valueToDigest)`
  Returns the digest for the input data.
  `String`
  `hmacHex(File valueToDigest)`
  Returns the digest for the file.
  `String`
  `hmacHex(InputStream valueToDigest)`
  Returns the digest for the stream.
  `String`
  `hmacHex(String valueToDigest)`
  Returns the digest for the input data.
  `String`
  `hmacHex(ByteBuffer valueToDigest)`
  Returns the digest for the input data.
  `String`
  `hmacHex(Path valueToDigest)`
  Returns the digest for the path.
  `static byte[]`
  `hmacMd5(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(byte[])`.
  `static byte[]`
  `hmacMd5(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(InputStream)`.
  `static byte[]`
  `hmacMd5(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmac(String)`.
  `static String`
  `hmacMd5Hex(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(byte[])`.
  `static String`
  `hmacMd5Hex(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(InputStream)`.
  `static String`
  `hmacMd5Hex(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmacHex(String)`.
  `static byte[]`
  `hmacSha1(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(byte[])`.
  `static byte[]`
  `hmacSha1(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(InputStream)`.
  `static byte[]`
  `hmacSha1(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmac(String)`.
  `static String`
  `hmacSha1Hex(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(byte[])`
  `static String`
  `hmacSha1Hex(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(InputStream)`.
  `static String`
  `hmacSha1Hex(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmacHex(String)`.
  `static byte[]`
  `hmacSha256(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(byte[])`.
  `static byte[]`
  `hmacSha256(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(InputStream)`.
  `static byte[]`
  `hmacSha256(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmac(String)`.
  `static String`
  `hmacSha256Hex(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(byte[])`.
  `static String`
  `hmacSha256Hex(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(InputStream)`.
  `static String`
  `hmacSha256Hex(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmacHex(String)`.
  `static byte[]`
  `hmacSha384(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(byte[])`.
  `static byte[]`
  `hmacSha384(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(InputStream)`.
  `static byte[]`
  `hmacSha384(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmac(String)`.
  `static String`
  `hmacSha384Hex(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(byte[])`.
  `static String`
  `hmacSha384Hex(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(InputStream)`.
  `static String`
  `hmacSha384Hex(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmacHex(String)`.
  `static byte[]`
  `hmacSha512(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(byte[])`.
  `static byte[]`
  `hmacSha512(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(InputStream)`.
  `static byte[]`
  `hmacSha512(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmac(String)`.
  `static String`
  `hmacSha512Hex(byte[] key, byte[] valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(byte[])`.
  `static String`
  `hmacSha512Hex(byte[] key, InputStream valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(InputStream)`.
  `static String`
  `hmacSha512Hex(String key, String valueToDigest)`
  Deprecated.
  (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmacHex(String)`.
  `static boolean`
  `isAvailable(String name)`
  Tests whether this algorithm is available
  `static boolean`
  `isAvailable(HmacAlgorithms hmacAlgorithms)`
  Tests whether this algorithm is available
  `static Mac`
  `updateHmac(Mac mac, byte[] valueToDigest)`
  Resets and then updates the given `Mac` with the value.
  `static Mac`
  `updateHmac(Mac mac, InputStream valueToDigest)`
  Resets and then updates the given `Mac` with the value.
  `static Mac`
  `updateHmac(Mac mac, String valueToDigest)`
  Resets and then updates the given `Mac` with the value.

  ### Methods inherited from class java.lang.Object

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

- ## Constructor Details

  - ### HmacUtils

    @Deprecated public HmacUtils()
    Deprecated.
    Since 1.11; only useful to preserve binary compatibility.
    Preserves binary compatibility only. As for previous versions does not provide useful behavior.

  - ### HmacUtils

    public HmacUtils(HmacAlgorithms algorithm, byte[] key)
    Creates an instance using the provided algorithm type.
    Parameters:
      `algorithm` - to use.
      `key` - The key to use.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    Since:
      1.11

  - ### HmacUtils

    public HmacUtils(HmacAlgorithms algorithm, String key)
    Creates an instance using the provided algorithm type.
    Parameters:
      `algorithm` - to use.
      `key` - The key to use.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    Since:
      1.11

  - ### HmacUtils

    public HmacUtils(String algorithm, byte[] key)
    Creates an instance using the provided algorithm type.
    Parameters:
      `algorithm` - to use.
      `key` - The key to use.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    Since:
      1.11

  - ### HmacUtils

    public HmacUtils(String algorithm, String key)
    Creates an instance using the provided algorithm type.
    Parameters:
      `algorithm` - to use.
      `key` - The key to use.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    Since:
      1.11

- ## Method Details

  - ### getHmacMd5

    @Deprecated public static Mac getHmacMd5(byte[] key)
    Deprecated.
    (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_MD5, byte[])`.
    Returns an initialized `Mac` for the HmacMD5 algorithm.

    Every implementation of the Java platform is required to support this standard Mac algorithm.

    Parameters:
      `key` - The key for the keyed digest (must not be null).
    Returns:
      A Mac instance initialized with the given key.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    See Also:
      - `Mac.getInstance(String)`
      - `Mac.init(Key)`

  - ### getHmacSha1

    @Deprecated public static Mac getHmacSha1(byte[] key)
    Deprecated.
    (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_1, byte[])`.
    Returns an initialized `Mac` for the HmacSHA1 algorithm.

    Every implementation of the Java platform is required to support this standard Mac algorithm.

    Parameters:
      `key` - The key for the keyed digest (must not be null).
    Returns:
      A Mac instance initialized with the given key.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    See Also:
      - `Mac.getInstance(String)`
      - `Mac.init(Key)`

  - ### getHmacSha256

    @Deprecated public static Mac getHmacSha256(byte[] key)
    Deprecated.
    (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_256, byte[])`.
    Returns an initialized `Mac` for the HmacSHA256 algorithm.

    Every implementation of the Java platform is required to support this standard Mac algorithm.

    Parameters:
      `key` - The key for the keyed digest (must not be null).
    Returns:
      A Mac instance initialized with the given key.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    See Also:
      - `Mac.getInstance(String)`
      - `Mac.init(Key)`

  - ### getHmacSha384

    @Deprecated public static Mac getHmacSha384(byte[] key)
    Deprecated.
    (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_384, byte[])`.
    Returns an initialized `Mac` for the HmacSHA384 algorithm.

    Every implementation of the Java platform is not required to support this Mac algorithm.

    Parameters:
      `key` - The key for the keyed digest (must not be null).
    Returns:
      A Mac instance initialized with the given key.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    See Also:
      - `Mac.getInstance(String)`
      - `Mac.init(Key)`

  - ### getHmacSha512

    @Deprecated public static Mac getHmacSha512(byte[] key)
    Deprecated.
    (1.11) Use `getInitializedMac(HmacAlgorithms.HMAC_SHA_512, byte[])`.
    Returns an initialized `Mac` for the HmacSHA512 algorithm.

    Every implementation of the Java platform is not required to support this Mac algorithm.

    Parameters:
      `key` - The key for the keyed digest (must not be null).
    Returns:
      A Mac instance initialized with the given key.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    See Also:
      - `Mac.getInstance(String)`
      - `Mac.init(Key)`

  - ### getInitializedMac

    public static Mac getInitializedMac(HmacAlgorithms algorithm, byte[] key)
    Returns an initialized `Mac` for the given `algorithm`.
    Parameters:
      `algorithm` - The name of the algorithm requested. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard algorithm names.
      `key` - The key for the keyed digest (must not be null).
    Returns:
      A Mac instance initialized with the given key.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    See Also:
      - `Mac.getInstance(String)`
      - `Mac.init(Key)`

  - ### getInitializedMac

    public static Mac getInitializedMac(String algorithm, byte[] key)
    Returns an initialized `Mac` for the given `algorithm`.
    Parameters:
      `algorithm` - The name of the algorithm requested. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard algorithm names.
      `key` - The key for the keyed digest (must not be null).
    Returns:
      A Mac instance initialized with the given key.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.
    See Also:
      - `Mac.getInstance(String)`
      - `Mac.init(Key)`

  - ### hmacMd5

    @Deprecated public static byte[] hmacMd5(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(byte[])`.
    Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacMD5 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacMd5

    @Deprecated public static byte[] hmacMd5(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(InputStream)`.
    Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest. The InputStream must not be null and will not be closed.
    Returns:
      HmacMD5 MAC for the given key and value.
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacMd5

    @Deprecated public static byte[] hmacMd5(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmac(String)`.
    Returns a HmacMD5 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacMD5 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacMd5Hex

    @Deprecated public static String hmacMd5Hex(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(byte[])`.
    Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacMd5Hex

    @Deprecated public static String hmacMd5Hex(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(InputStream)`.
    Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest. The InputStream must not be null and will not be closed.
    Returns:
      HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase).
    Throws:
      `IOException` - Thrown if an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacMd5Hex

    @Deprecated public static String hmacMd5Hex(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmacHex(String)`.
    Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha1

    @Deprecated public static byte[] hmacSha1(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(byte[])`.
    Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA1 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha1

    @Deprecated public static byte[] hmacSha1(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(InputStream)`.
    Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest. The InputStream must not be null and will not be closed.
    Returns:
      HmacSHA1 MAC for the given key and value.
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha1

    @Deprecated public static byte[] hmacSha1(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmac(String)`.
    Returns a HmacSHA1 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA1 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha1Hex

    @Deprecated public static String hmacSha1Hex(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(byte[])`
    Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha1Hex

    @Deprecated public static String hmacSha1Hex(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(InputStream)`.
    Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest. The InputStream must not be null and will not be closed.
    Returns:
      HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha1Hex

    @Deprecated public static String hmacSha1Hex(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmacHex(String)`.
    Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha256

    @Deprecated public static byte[] hmacSha256(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(byte[])`.
    Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA256 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha256

    @Deprecated public static byte[] hmacSha256(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(InputStream)`.
    Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest. The InputStream must not be null and will not be closed.
    Returns:
      HmacSHA256 MAC for the given key and value.
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha256

    @Deprecated public static byte[] hmacSha256(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmac(String)`.
    Returns a HmacSHA256 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA256 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha256Hex

    @Deprecated public static String hmacSha256Hex(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(byte[])`.
    Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha256Hex

    @Deprecated public static String hmacSha256Hex(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(InputStream)`.
    Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest.

      The InputStream must not be null and will not be closed.

    Returns:
      HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha256Hex

    @Deprecated public static String hmacSha256Hex(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmacHex(String)`.
    Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha384

    @Deprecated public static byte[] hmacSha384(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(byte[])`.
    Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA384 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha384

    @Deprecated public static byte[] hmacSha384(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(InputStream)`.
    Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest.

      The InputStream must not be null and will not be closed.

    Returns:
      HmacSHA384 MAC for the given key and value.
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha384

    @Deprecated public static byte[] hmacSha384(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmac(String)`.
    Returns a HmacSHA384 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA384 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha384Hex

    @Deprecated public static String hmacSha384Hex(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(byte[])`.
    Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha384Hex

    @Deprecated public static String hmacSha384Hex(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(InputStream)`.
    Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest.

      The InputStream must not be null and will not be closed.

    Returns:
      HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha384Hex

    @Deprecated public static String hmacSha384Hex(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmacHex(String)`.
    Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha512

    @Deprecated public static byte[] hmacSha512(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(byte[])`.
    Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA512 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha512

    @Deprecated public static byte[] hmacSha512(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(InputStream)`.
    Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest.

      The InputStream must not be null and will not be closed.

    Returns:
      HmacSHA512 MAC for the given key and value.
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha512

    @Deprecated public static byte[] hmacSha512(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmac(String)`.
    Returns a HmacSHA512 Message Authentication Code (MAC) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA512 MAC for the given key and value.
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha512Hex

    @Deprecated public static String hmacSha512Hex(byte[] key, byte[] valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(byte[])`.
    Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha512Hex

    @Deprecated public static String hmacSha512Hex(byte[] key, InputStream valueToDigest) throws IOException
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(InputStream)`.
    Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest.

      The InputStream must not be null and will not be closed.

    Returns:
      HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### hmacSha512Hex

    @Deprecated public static String hmacSha512Hex(String key, String valueToDigest)
    Deprecated.
    (1.11) Use `new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmacHex(String)`.
    Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value.
    Parameters:
      `key` - The key for the keyed digest (must not be null).
      `valueToDigest` - The value (data) which should to digest (maybe empty or null).
    Returns:
      HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase).
    Throws:
      `IllegalArgumentException` - Thrown if a `NoSuchAlgorithmException` is caught or key is null or key is invalid.

  - ### isAvailable

    public static boolean isAvailable(HmacAlgorithms hmacAlgorithms)
    Tests whether this algorithm is available
    Parameters:
      `hmacAlgorithms` - The HmacAlgorithms to check.
    Returns:
      whether this algorithm is available.
    Since:
      1.11

  - ### isAvailable

    public static boolean isAvailable(String name)
    Tests whether this algorithm is available
    Parameters:
      `name` - The name to check.
    Returns:
      whether this algorithm is available.
    Since:
      1.11

  - ### updateHmac

    public static Mac updateHmac(Mac mac, byte[] valueToDigest)
    Resets and then updates the given `Mac` with the value.
    Parameters:
      `mac` - The initialized `Mac` to update.
      `valueToDigest` - The value to update the `Mac` with (maybe null or empty).
    Returns:
      The updated `Mac`.
    Throws:
      `IllegalStateException` - if the Mac was not initialized.

  - ### updateHmac

    public static Mac updateHmac(Mac mac, InputStream valueToDigest) throws IOException
    Resets and then updates the given `Mac` with the value.
    Parameters:
      `mac` - The initialized `Mac` to update.
      `valueToDigest` - The value to update the `Mac` with.

      The InputStream must not be null and will not be closed.

    Returns:
      The updated `Mac`.
    Throws:
      `IOException` - If an I/O error occurs.
      `IllegalStateException` - If the Mac was not initialized.

  - ### updateHmac

    public static Mac updateHmac(Mac mac, String valueToDigest)
    Resets and then updates the given `Mac` with the value.
    Parameters:
      `mac` - The initialized `Mac` to update.
      `valueToDigest` - The value to update the `Mac` with (maybe null or empty).
    Returns:
      The updated `Mac`.
    Throws:
      `IllegalStateException` - if the Mac was not initialized.

  - ### hmac

    public byte[] hmac(byte[] valueToDigest)
    Returns the digest for the input data.
    Parameters:
      `valueToDigest` - The input to use.
    Returns:
      The digest as a byte[].
    Since:
      1.11

  - ### hmac

    public byte[] hmac(ByteBuffer valueToDigest)
    Returns the digest for the input data.
    Parameters:
      `valueToDigest` - The input to use.
    Returns:
      The digest as a byte[].
    Since:
      1.11

  - ### hmac

    public byte[] hmac(File valueToDigest) throws IOException
    Returns the digest for the file.
    Parameters:
      `valueToDigest` - The file to use.
    Returns:
      The digest.
    Throws:
      `IOException` - If an I/O error occurs.
    Since:
      1.11

  - ### hmac

    public byte[] hmac(InputStream valueToDigest) throws IOException
    Returns the digest for the stream.
    Parameters:
      `valueToDigest` - The data to use.

      The InputStream must not be null and will not be closed.

    Returns:
      The digest.
    Throws:
      `IOException` - If an I/O error occurs.
    Since:
      1.11

  - ### hmac

    public byte[] hmac(Path valueToDigest) throws IOException
    Returns the digest for the file.
    Parameters:
      `valueToDigest` - The path to use.
    Returns:
      The digest.
    Throws:
      `IOException` - If an I/O error occurs.
    Since:
      1.19.0

  - ### hmac

    public byte[] hmac(String valueToDigest)
    Returns the digest for the input data.
    Parameters:
      `valueToDigest` - The input to use, treated as UTF-8.
    Returns:
      The digest as a byte[].
    Since:
      1.11

  - ### hmacHex

    public String hmacHex(byte[] valueToDigest)
    Returns the digest for the input data.
    Parameters:
      `valueToDigest` - The input to use.
    Returns:
      The digest as a hexadecimal String.
    Since:
      1.11

  - ### hmacHex

    public String hmacHex(ByteBuffer valueToDigest)
    Returns the digest for the input data.
    Parameters:
      `valueToDigest` - The input to use.
    Returns:
      The digest as a hexadecimal String.
    Since:
      1.11

  - ### hmacHex

    public String hmacHex(File valueToDigest) throws IOException
    Returns the digest for the file.
    Parameters:
      `valueToDigest` - The file to use.
    Returns:
      The digest as a hexadecimal String.
    Throws:
      `IOException` - If an I/O error occurs.
    Since:
      1.11

  - ### hmacHex

    public String hmacHex(InputStream valueToDigest) throws IOException
    Returns the digest for the stream.
    Parameters:
      `valueToDigest` - The data to use.

      The InputStream must not be null and will not be closed.

    Returns:
      The digest as a hexadecimal String.
    Throws:
      `IOException` - If an I/O error occurs.
    Since:
      1.11

  - ### hmacHex

    public String hmacHex(Path valueToDigest) throws IOException
    Returns the digest for the path.
    Parameters:
      `valueToDigest` - The path to use.
    Returns:
      The digest as a hexadecimal String.
    Throws:
      `IOException` - If an I/O error occurs.
    Since:
      1.19.0

  - ### hmacHex

    public String hmacHex(String valueToDigest)
    Returns the digest for the input data.
    Parameters:
      `valueToDigest` - The input to use, treated as UTF-8.
    Returns:
      The digest as a hexadecimal String.
    Since:
      1.11