public final class HmacUtils extends Object
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 re-use
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"));
| Constructor and Description |
|---|
HmacUtils()
Deprecated.
since 1.11; only useful to preserve binary compatibility
|
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.
|
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.
|
| Modifier and Type | Method and 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(HmacAlgorithms algorithm,
byte[] key)
Returns an initialized
Mac for the given algorithm. |
static Mac |
getInitializedMac(String algorithm,
byte[] key)
Returns an initialized
Mac for the given algorithm. |
byte[] |
hmac(byte[] valueToDigest)
Returns the digest for the input data.
|
byte[] |
hmac(ByteBuffer 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.
|
String |
hmacHex(byte[] valueToDigest)
Returns the digest for the input data.
|
String |
hmacHex(ByteBuffer 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.
|
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(HmacAlgorithms name)
Returns whether this algorithm is available
|
static boolean |
isAvailable(String name)
Returns 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. |
@Deprecated public HmacUtils()
public HmacUtils(String algorithm, byte[] key)
algorithm - to usekey - the key to useIllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.public HmacUtils(String algorithm, String key)
algorithm - to usekey - the key to useIllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.public HmacUtils(HmacAlgorithms algorithm, String key)
algorithm - to usekey - the key to useIllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.public HmacUtils(HmacAlgorithms algorithm, byte[] key)
algorithm - to use.key - the key to useIllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.public static boolean isAvailable(String name)
name - the name to checkpublic static boolean isAvailable(HmacAlgorithms name)
name - the name to check@Deprecated public static Mac getHmacMd5(byte[] key)
getInitializedMac(HmacAlgorithms.HMAC_MD5, byte[])Mac for the HmacMD5 algorithm.
Every implementation of the Java platform is required to support this standard Mac algorithm.
key - The key for the keyed digest (must not be null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.Mac.getInstance(String),
Mac.init(Key)@Deprecated public static Mac getHmacSha1(byte[] key)
getInitializedMac(HmacAlgorithms.HMAC_SHA_1, byte[])Mac for the HmacSHA1 algorithm.
Every implementation of the Java platform is required to support this standard Mac algorithm.
key - The key for the keyed digest (must not be null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.Mac.getInstance(String),
Mac.init(Key)@Deprecated public static Mac getHmacSha256(byte[] key)
getInitializedMac(HmacAlgorithms.HMAC_SHA_256, byte[])Mac for the HmacSHA256 algorithm.
Every implementation of the Java platform is required to support this standard Mac algorithm.
key - The key for the keyed digest (must not be null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.Mac.getInstance(String),
Mac.init(Key)@Deprecated public static Mac getHmacSha384(byte[] key)
getInitializedMac(HmacAlgorithms.HMAC_SHA_384, byte[])Mac for the HmacSHA384 algorithm.
Every implementation of the Java platform is not required to support this Mac algorithm.
key - The key for the keyed digest (must not be null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.Mac.getInstance(String),
Mac.init(Key)@Deprecated public static Mac getHmacSha512(byte[] key)
getInitializedMac(HmacAlgorithms.HMAC_SHA_512, byte[])Mac for the HmacSHA512 algorithm.
Every implementation of the Java platform is not required to support this Mac algorithm.
key - The key for the keyed digest (must not be null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.Mac.getInstance(String),
Mac.init(Key)public static Mac getInitializedMac(HmacAlgorithms algorithm, byte[] key)
Mac for the given algorithm.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)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.Mac.getInstance(String),
Mac.init(Key)public static Mac getInitializedMac(String algorithm, byte[] key)
Mac for the given algorithm.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)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.Mac.getInstance(String),
Mac.init(Key)@Deprecated public static byte[] hmacMd5(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacMd5(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmac(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacMd5(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmac(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacMd5Hex(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacMd5Hex(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacMd5Hex(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmacHex(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha1(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha1(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmac(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha1(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmac(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha1Hex(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha1Hex(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha1Hex(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmacHex(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha256(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha256(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmac(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha256(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmac(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha256Hex(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha256Hex(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha256Hex(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmacHex(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha384(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha384(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmac(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha384(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmac(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha384Hex(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha384Hex(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha384Hex(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmacHex(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha512(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha512(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmac(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static byte[] hmacSha512(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmac(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha512Hex(byte[] key, byte[] valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(byte[])key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha512Hex(byte[] key, InputStream valueToDigest) throws IOException
new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(InputStream)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
IOException - If an I/O error occurs.IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.@Deprecated public static String hmacSha512Hex(String key, String valueToDigest)
new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmacHex(String)key - The key for the keyed digest (must not be null)valueToDigest - The value (data) which should to digest (maybe empty or null)IllegalArgumentException - when a NoSuchAlgorithmException is caught or key is null or key is invalid.public static Mac updateHmac(Mac mac, byte[] valueToDigest)
Mac with the value.mac - the initialized Mac to updatevalueToDigest - the value to update the Mac with (maybe null or empty)MacIllegalStateException - if the Mac was not initializedpublic static Mac updateHmac(Mac mac, InputStream valueToDigest) throws IOException
Mac with the value.mac - the initialized Mac to updatevalueToDigest - the value to update the Mac with
The InputStream must not be null and will not be closed
MacIOException - If an I/O error occurs.IllegalStateException - If the Mac was not initializedpublic static Mac updateHmac(Mac mac, String valueToDigest)
Mac with the value.mac - the initialized Mac to updatevalueToDigest - the value to update the Mac with (maybe null or empty)MacIllegalStateException - if the Mac was not initializedpublic byte[] hmac(byte[] valueToDigest)
valueToDigest - the input to usepublic String hmacHex(byte[] valueToDigest)
valueToDigest - the input to usepublic byte[] hmac(String valueToDigest)
valueToDigest - the input to use, treated as UTF-8public String hmacHex(String valueToDigest)
valueToDigest - the input to use, treated as UTF-8public byte[] hmac(ByteBuffer valueToDigest)
valueToDigest - the input to usepublic String hmacHex(ByteBuffer valueToDigest)
valueToDigest - the input to usepublic byte[] hmac(InputStream valueToDigest) throws IOException
valueToDigest - the data to use
The InputStream must not be null and will not be closed
IOException - If an I/O error occurs.public String hmacHex(InputStream valueToDigest) throws IOException
valueToDigest - the data to use
The InputStream must not be null and will not be closed
IOException - If an I/O error occurs.public byte[] hmac(File valueToDigest) throws IOException
valueToDigest - the file to useIOException - If an I/O error occurs.public String hmacHex(File valueToDigest) throws IOException
valueToDigest - the file to useIOException - If an I/O error occurs.Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.