public class MessageDigestUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ALGORITHM_MD2
The MD2 message digest algorithm as defined in RFC 1319.
|
static String |
ALGORITHM_MD5
The MD5 message digest algorithm as defined in RFC 1321.
|
static String |
ALGORITHM_SHA1
The SHA1 algorithm defined in FIPS PUB 180-4.
|
static String |
ALGORITHM_SHA2_224
The SHA-224 algorithm defined in FIPS PUB 180-4.
|
static String |
ALGORITHM_SHA2_256
The SHA-256 algorithm defined in FIPS PUB 180-4.
|
static String |
ALGORITHM_SHA2_384
The SHA-384 algorithm defined in FIPS PUB 180-4.
|
static String |
ALGORITHM_SHA2_512
The SHA-512 algorithm defined in FIPS PUB 180-4.
|
static String |
ALGORITHM_SHA2_512_224
The SHA-512/224 algorithm defined in FIPS PUB 180-4.
|
static String |
ALGORITHM_SHA2_512_256
The SHA-512/256 algorithm defined in FIPS PUB 180-4.
|
static String |
ALGORITHM_SHA3_224
The SHA3-224 Permutation-based hash and extendable-output function as defined in FIPS PUB 202.
|
static String |
ALGORITHM_SHA3_256
The SHA3-256 Permutation-based hash and extendable-output function as defined in FIPS PUB 202.
|
static String |
ALGORITHM_SHA3_384
The SHA3-384 Permutation-based hash and extendable-output function as defined in FIPS PUB 202.
|
static String |
ALGORITHM_SHA3_512
The SHA3-512 Permutation-based hash and extendable-output function as defined in FIPS PUB 202.
|
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
hashBytes(byte[] bytes,
String algorithm)
Hashes the given bytes using the given MessageDigest algorithm.
|
static byte[] |
hashBytes(byte[] bytes,
String algorithm,
Provider provider,
String providerName)
Hashes the given bytes using the given MessageDigest algorithm.
|
static String |
hashString(String text,
Charset charset,
String algorithm)
Hashes the given text using the given MessageDigest algorithm and encodes the result using a Base64Encoder.
|
static String |
hashString(String text,
Charset charset,
String algorithm,
Provider provider,
String providerName)
Hashes the given text using the given MessageDigest algorithm and encodes the result using a Base64Encoder.
|
static String |
hashString(String text,
Charset charset,
String algorithm,
Provider provider,
String providerName,
TextEncoder encoder)
Hashes the given text using the given MessageDigest algorithm and encodes the result using the given TextEncoder.
|
static String |
hashString(String text,
Charset charset,
String algorithm,
TextEncoder encoder)
Hashes the given text using the given MessageDigest algorithm and encodes the result using the given TextEncoder.
|
static String |
hashString(String text,
String algorithm)
Hashes the given text using the given MessageDigest algorithm and encodes the result using a Base64Encoder.
|
static String |
hashString(String text,
String algorithm,
Provider provider,
String providerName)
Hashes the given text using the given MessageDigest algorithm and encodes the result using a Base64Encoder.
|
static String |
hashString(String text,
String algorithm,
Provider provider,
String providerName,
TextEncoder encoder)
Hashes the given text using the given MessageDigest algorithm and encodes the result using the given TextEncoder.
|
static String |
hashString(String text,
String algorithm,
TextEncoder encoder)
Hashes the given text using the given MessageDigest algorithm and encodes the result using the given TextEncoder.
|
public static final String ALGORITHM_MD2
public static final String ALGORITHM_MD5
public static final String ALGORITHM_SHA1
public static final String ALGORITHM_SHA2_224
public static final String ALGORITHM_SHA2_256
public static final String ALGORITHM_SHA2_384
public static final String ALGORITHM_SHA2_512
public static final String ALGORITHM_SHA2_512_224
public static final String ALGORITHM_SHA2_512_256
public static final String ALGORITHM_SHA3_224
public static final String ALGORITHM_SHA3_256
public static final String ALGORITHM_SHA3_384
public static final String ALGORITHM_SHA3_512
public static String hashString(String text, String algorithm) throws NoSuchAlgorithmException
text - the textalgorithm - the MessageDigest algorithmNoSuchAlgorithmException - NoSuchAlgorithmExceptionpublic static String hashString(String text, Charset charset, String algorithm) throws NoSuchAlgorithmException
text - the textcharset - the Charset used for the given textalgorithm - the MessageDigest algorithmNoSuchAlgorithmException - NoSuchAlgorithmExceptionpublic static String hashString(String text, String algorithm, TextEncoder encoder) throws NoSuchAlgorithmException
text - the textalgorithm - the MessageDigest algorithmencoder - the TextEncoderNoSuchAlgorithmException - NoSuchAlgorithmExceptionpublic static String hashString(String text, Charset charset, String algorithm, TextEncoder encoder) throws NoSuchAlgorithmException
text - the textcharset - the Charset used for the given textalgorithm - the MessageDigest algorithmencoder - the TextEncoderNoSuchAlgorithmException - NoSuchAlgorithmExceptionpublic static String hashString(String text, String algorithm, Provider provider, String providerName) throws NoSuchAlgorithmException, NoSuchProviderException
text - the textalgorithm - the MessageDigest algorithmprovider - the JCE-compliant provider (may be null)providerName - the name of the JCE-compliant provider (may be null)NoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionpublic static String hashString(String text, Charset charset, String algorithm, Provider provider, String providerName) throws NoSuchAlgorithmException, NoSuchProviderException
text - the textcharset - the Charset used for the given textalgorithm - the MessageDigest algorithmprovider - the JCE-compliant provider (may be null)providerName - the name of the JCE-compliant provider (may be null)NoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionpublic static String hashString(String text, String algorithm, Provider provider, String providerName, TextEncoder encoder) throws NoSuchAlgorithmException, NoSuchProviderException
text - the textalgorithm - the MessageDigest algorithmprovider - the JCE-compliant provider (may be null)providerName - the name of the JCE-compliant provider (may be null)encoder - the TextEncoderNoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionpublic static String hashString(String text, Charset charset, String algorithm, Provider provider, String providerName, TextEncoder encoder) throws NoSuchAlgorithmException, NoSuchProviderException
text - the textcharset - the Charset used for the given textalgorithm - the MessageDigest algorithmprovider - the JCE-compliant provider (may be null)providerName - the name of the JCE-compliant provider (may be null)encoder - the TextEncoderNoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderExceptionpublic static byte[] hashBytes(byte[] bytes,
String algorithm)
throws NoSuchAlgorithmException
bytes - the bytesalgorithm - the MessageDigest algorithmNoSuchAlgorithmException - NoSuchAlgorithmExceptionpublic static byte[] hashBytes(byte[] bytes,
String algorithm,
Provider provider,
String providerName)
throws NoSuchAlgorithmException,
NoSuchProviderException
bytes - the bytesalgorithm - the MessageDigest algorithmprovider - the JCE-compliant provider (may be null)providerName - the name of the JCE-compliant provider (may be null)NoSuchAlgorithmException - NoSuchAlgorithmExceptionNoSuchProviderException - NoSuchProviderException