public abstract class DigestUtils
extends java.lang.Object
Mainly for internal use within the framework; consider Apache Commons Codec for a more comprehensive suite of digest utilities.
Modifier and Type | Field and Description |
---|---|
private static char[] |
HEX_CHARS |
private static java.lang.String |
MD5_ALGORITHM_NAME |
Constructor and Description |
---|
DigestUtils() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.StringBuilder |
appendDigestAsHex(java.lang.String algorithm,
byte[] bytes,
java.lang.StringBuilder builder) |
private static java.lang.StringBuilder |
appendDigestAsHex(java.lang.String algorithm,
java.io.InputStream inputStream,
java.lang.StringBuilder builder) |
static java.lang.StringBuilder |
appendMd5DigestAsHex(byte[] bytes,
java.lang.StringBuilder builder)
Append a hexadecimal string representation of the MD5 digest of the given
bytes to the given
StringBuilder . |
static java.lang.StringBuilder |
appendMd5DigestAsHex(java.io.InputStream inputStream,
java.lang.StringBuilder builder)
Append a hexadecimal string representation of the MD5 digest of the given
inputStream to the given
StringBuilder . |
private static byte[] |
digest(java.lang.String algorithm,
byte[] bytes) |
private static byte[] |
digest(java.lang.String algorithm,
java.io.InputStream inputStream) |
private static char[] |
digestAsHexChars(java.lang.String algorithm,
byte[] bytes) |
private static char[] |
digestAsHexChars(java.lang.String algorithm,
java.io.InputStream inputStream) |
private static java.lang.String |
digestAsHexString(java.lang.String algorithm,
byte[] bytes) |
private static java.lang.String |
digestAsHexString(java.lang.String algorithm,
java.io.InputStream inputStream) |
private static char[] |
encodeHex(byte[] bytes) |
private static java.security.MessageDigest |
getDigest(java.lang.String algorithm)
Create a new
MessageDigest with the given algorithm. |
static byte[] |
md5Digest(byte[] bytes)
Calculate the MD5 digest of the given bytes.
|
static byte[] |
md5Digest(java.io.InputStream inputStream)
Calculate the MD5 digest of the given stream.
|
static java.lang.String |
md5DigestAsHex(byte[] bytes)
Return a hexadecimal string representation of the MD5 digest of the given bytes.
|
static java.lang.String |
md5DigestAsHex(java.io.InputStream inputStream)
Return a hexadecimal string representation of the MD5 digest of the given stream.
|
private static final java.lang.String MD5_ALGORITHM_NAME
private static final char[] HEX_CHARS
public static byte[] md5Digest(byte[] bytes)
bytes
- the bytes to calculate the digest overpublic static byte[] md5Digest(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- the InputStream to calculate the digest overjava.io.IOException
public static java.lang.String md5DigestAsHex(byte[] bytes)
bytes
- the bytes to calculate the digest overpublic static java.lang.String md5DigestAsHex(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- the InputStream to calculate the digest overjava.io.IOException
public static java.lang.StringBuilder appendMd5DigestAsHex(byte[] bytes, java.lang.StringBuilder builder)
StringBuilder
.bytes
- the bytes to calculate the digest overbuilder
- the string builder to append the digest topublic static java.lang.StringBuilder appendMd5DigestAsHex(java.io.InputStream inputStream, java.lang.StringBuilder builder) throws java.io.IOException
StringBuilder
.inputStream
- the inputStream to calculate the digest overbuilder
- the string builder to append the digest tojava.io.IOException
private static java.security.MessageDigest getDigest(java.lang.String algorithm)
MessageDigest
with the given algorithm.
Necessary because MessageDigest
is not thread-safe.private static byte[] digest(java.lang.String algorithm, byte[] bytes)
private static byte[] digest(java.lang.String algorithm, java.io.InputStream inputStream) throws java.io.IOException
java.io.IOException
private static java.lang.String digestAsHexString(java.lang.String algorithm, byte[] bytes)
private static java.lang.String digestAsHexString(java.lang.String algorithm, java.io.InputStream inputStream) throws java.io.IOException
java.io.IOException
private static java.lang.StringBuilder appendDigestAsHex(java.lang.String algorithm, byte[] bytes, java.lang.StringBuilder builder)
private static java.lang.StringBuilder appendDigestAsHex(java.lang.String algorithm, java.io.InputStream inputStream, java.lang.StringBuilder builder) throws java.io.IOException
java.io.IOException
private static char[] digestAsHexChars(java.lang.String algorithm, byte[] bytes)
private static char[] digestAsHexChars(java.lang.String algorithm, java.io.InputStream inputStream) throws java.io.IOException
java.io.IOException
private static char[] encodeHex(byte[] bytes)