|
|
@ -20,11 +20,10 @@ import java.security.MessageDigest; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Miscellaneous method for calculating digests. |
|
|
|
* Miscellaneous methods for calculating digests. |
|
|
|
|
|
|
|
|
|
|
|
* <p>Mainly for internal use within the framework; consider |
|
|
|
* <p>Mainly for internal use within the framework; consider |
|
|
|
* <a href="http://jakarta.apache.org/commons/codec/">Jakarta's Commons Codec</a> |
|
|
|
* <a href="http://commons.apache.org/codec/">Apache Commons Codec</a> for a |
|
|
|
* for a more comprehensive suite of Digest utilities. |
|
|
|
* more comprehensive suite of digest utilities. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Arjen Poutsma |
|
|
|
* @author Arjen Poutsma |
|
|
|
* @since 3.0 |
|
|
|
* @since 3.0 |
|
|
@ -47,7 +46,8 @@ public abstract class DigestUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return a hexadecimal string representation of the MD5 digest of the given bytes. |
|
|
|
* Return a hexadecimal string representation of the MD5 digest of the given |
|
|
|
|
|
|
|
* bytes. |
|
|
|
* @param bytes the bytes to calculate the digest over |
|
|
|
* @param bytes the bytes to calculate the digest over |
|
|
|
* @return a hexadecimal digest string |
|
|
|
* @return a hexadecimal digest string |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -56,7 +56,8 @@ public abstract class DigestUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Append a hexadecima string representation of the MD5 digest of the given bytes to the given {@link StringBuilder}. |
|
|
|
* Append a hexadecimal string representation of the MD5 digest of the given |
|
|
|
|
|
|
|
* bytes to the given {@link StringBuilder}. |
|
|
|
* @param bytes the bytes to calculate the digest over |
|
|
|
* @param bytes the bytes to calculate the digest over |
|
|
|
* @param builder the string builder to append the digest to |
|
|
|
* @param builder the string builder to append the digest to |
|
|
|
* @return the given string builder |
|
|
|
* @return the given string builder |
|
|
@ -66,8 +67,8 @@ public abstract class DigestUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Creates a new {@link MessageDigest} with the given algorithm. Necessary because {@code MessageDigest} is not |
|
|
|
* Creates a new {@link MessageDigest} with the given algorithm. Necessary |
|
|
|
* thread-safe. |
|
|
|
* because {@code MessageDigest} is not thread-safe. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static MessageDigest getDigest(String algorithm) { |
|
|
|
private static MessageDigest getDigest(String algorithm) { |
|
|
|
try { |
|
|
|
try { |
|
|
@ -107,5 +108,4 @@ public abstract class DigestUtils { |
|
|
|
return chars; |
|
|
|
return chars; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|