Class DigestUtils
java.lang.Object
org.springframework.util.DigestUtils
Miscellaneous methods for calculating digests.
Mainly for internal use within the framework; consider Apache Commons Codec for a more comprehensive suite of digest utilities.
- Since:
- 3.0
- Author:
- Arjen Poutsma, Juergen Hoeller, Craig Andrews
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic StringBuilderappendMd5DigestAsHex(byte[] bytes, StringBuilder builder) Append a hexadecimal string representation of the MD5 digest of the given bytes to the givenStringBuilder.static StringBuilderappendMd5DigestAsHex(InputStream inputStream, StringBuilder builder) Append a hexadecimal string representation of the MD5 digest of the given inputStream to the givenStringBuilder.static byte[]md5Digest(byte[] bytes) Calculate the MD5 digest of the given bytes.static byte[]md5Digest(InputStream inputStream) Calculate the MD5 digest of the given stream.static Stringmd5DigestAsHex(byte[] bytes) Return a hexadecimal string representation of the MD5 digest of the given bytes.static Stringmd5DigestAsHex(InputStream inputStream) Return a hexadecimal string representation of the MD5 digest of the given stream.
- 
Constructor Details- 
DigestUtilspublic DigestUtils()
 
- 
- 
Method Details- 
md5Digestpublic static byte[] md5Digest(byte[] bytes) Calculate the MD5 digest of the given bytes.- Parameters:
- bytes- the bytes to calculate the digest over
- Returns:
- the digest
 
- 
md5DigestCalculate the MD5 digest of the given stream.This method does not close the input stream. - Parameters:
- inputStream- the InputStream to calculate the digest over
- Returns:
- the digest
- Throws:
- IOException
- Since:
- 4.2
 
- 
md5DigestAsHexReturn a hexadecimal string representation of the MD5 digest of the given bytes.- Parameters:
- bytes- the bytes to calculate the digest over
- Returns:
- a hexadecimal digest string
 
- 
md5DigestAsHexReturn a hexadecimal string representation of the MD5 digest of the given stream.This method does not close the input stream. - Parameters:
- inputStream- the InputStream to calculate the digest over
- Returns:
- a hexadecimal digest string
- Throws:
- IOException
- Since:
- 4.2
 
- 
appendMd5DigestAsHexAppend a hexadecimal string representation of the MD5 digest of the given bytes to the givenStringBuilder.- Parameters:
- bytes- the bytes to calculate the digest over
- builder- the string builder to append the digest to
- Returns:
- the given string builder
 
- 
appendMd5DigestAsHexpublic static StringBuilder appendMd5DigestAsHex(InputStream inputStream, StringBuilder builder) throws IOException Append a hexadecimal string representation of the MD5 digest of the given inputStream to the givenStringBuilder.This method does not close the input stream. - Parameters:
- inputStream- the inputStream to calculate the digest over
- builder- the string builder to append the digest to
- Returns:
- the given string builder
- Throws:
- IOException
- Since:
- 4.2
 
 
-