|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.codec.digest.DigestUtils
public class DigestUtils
Operations to simplify common MessageDigest tasks. This class is thread safe.
| Field Summary | |
|---|---|
private static int |
STREAM_BUFFER_LENGTH
|
| Constructor Summary | |
|---|---|
DigestUtils()
|
|
| Method Summary | |
|---|---|
private static byte[] |
digest(MessageDigest digest,
InputStream data)
Read through an InputStream and returns the digest for the data |
private static byte[] |
getBytesUtf8(String data)
Calls StringUtils.getBytesUtf8(String) |
(package private) static MessageDigest |
getDigest(String algorithm)
Returns a MessageDigest for the given algorithm. |
private static MessageDigest |
getMd5Digest()
Returns an MD5 MessageDigest. |
private static MessageDigest |
getSha256Digest()
Returns an SHA-256 digest. |
private static MessageDigest |
getSha384Digest()
Returns an SHA-384 digest. |
private static MessageDigest |
getSha512Digest()
Returns an SHA-512 digest. |
private static MessageDigest |
getShaDigest()
Returns an SHA-1 digest. |
static byte[] |
md5(byte[] data)
Calculates the MD5 digest and returns the value as a 16 element byte[]. |
static byte[] |
md5(InputStream data)
Calculates the MD5 digest and returns the value as a 16 element byte[]. |
static byte[] |
md5(String data)
Calculates the MD5 digest and returns the value as a 16 element byte[]. |
static String |
md5Hex(byte[] data)
Calculates the MD5 digest and returns the value as a 32 character hex string. |
static String |
md5Hex(InputStream data)
Calculates the MD5 digest and returns the value as a 32 character hex string. |
static String |
md5Hex(String data)
Calculates the MD5 digest and returns the value as a 32 character hex string. |
static byte[] |
sha(byte[] data)
Calculates the SHA-1 digest and returns the value as a byte[]. |
static byte[] |
sha(InputStream data)
Calculates the SHA-1 digest and returns the value as a byte[]. |
static byte[] |
sha(String data)
Calculates the SHA-1 digest and returns the value as a byte[]. |
static byte[] |
sha256(byte[] data)
Calculates the SHA-256 digest and returns the value as a byte[]. |
static byte[] |
sha256(InputStream data)
Calculates the SHA-256 digest and returns the value as a byte[]. |
static byte[] |
sha256(String data)
Calculates the SHA-256 digest and returns the value as a byte[]. |
static String |
sha256Hex(byte[] data)
Calculates the SHA-256 digest and returns the value as a hex string. |
static String |
sha256Hex(InputStream data)
Calculates the SHA-256 digest and returns the value as a hex string. |
static String |
sha256Hex(String data)
Calculates the SHA-256 digest and returns the value as a hex string. |
static byte[] |
sha384(byte[] data)
Calculates the SHA-384 digest and returns the value as a byte[]. |
static byte[] |
sha384(InputStream data)
Calculates the SHA-384 digest and returns the value as a byte[]. |
static byte[] |
sha384(String data)
Calculates the SHA-384 digest and returns the value as a byte[]. |
static String |
sha384Hex(byte[] data)
Calculates the SHA-384 digest and returns the value as a hex string. |
static String |
sha384Hex(InputStream data)
Calculates the SHA-384 digest and returns the value as a hex string. |
static String |
sha384Hex(String data)
Calculates the SHA-384 digest and returns the value as a hex string. |
static byte[] |
sha512(byte[] data)
Calculates the SHA-512 digest and returns the value as a byte[]. |
static byte[] |
sha512(InputStream data)
Calculates the SHA-512 digest and returns the value as a byte[]. |
static byte[] |
sha512(String data)
Calculates the SHA-512 digest and returns the value as a byte[]. |
static String |
sha512Hex(byte[] data)
Calculates the SHA-512 digest and returns the value as a hex string. |
static String |
sha512Hex(InputStream data)
Calculates the SHA-512 digest and returns the value as a hex string. |
static String |
sha512Hex(String data)
Calculates the SHA-512 digest and returns the value as a hex string. |
static String |
shaHex(byte[] data)
Calculates the SHA-1 digest and returns the value as a hex string. |
static String |
shaHex(InputStream data)
Calculates the SHA-1 digest and returns the value as a hex string. |
static String |
shaHex(String data)
Calculates the SHA-1 digest and returns the value as a hex string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int STREAM_BUFFER_LENGTH
| Constructor Detail |
|---|
public DigestUtils()
| Method Detail |
|---|
private static byte[] digest(MessageDigest digest,
InputStream data)
throws IOException
digest - The MessageDigest to use (e.g. MD5)data - Data to digest
IOException - On error reading from the streamprivate static byte[] getBytesUtf8(String data)
StringUtils.getBytesUtf8(String)
data - the String to encode
static MessageDigest getDigest(String algorithm)
MessageDigest for the given algorithm.
algorithm - the name of the algorithm requested. See Appendix A in the Java
Cryptography Architecture API Specification & Reference for information about standard algorithm
names.
RuntimeException - when a NoSuchAlgorithmException is caught.MessageDigest.getInstance(String)private static MessageDigest getMd5Digest()
RuntimeException - when a NoSuchAlgorithmException is caught.private static MessageDigest getSha256Digest()
Throws a RuntimeException on JRE versions prior to 1.4.0.
RuntimeException - when a NoSuchAlgorithmException is caught.private static MessageDigest getSha384Digest()
Throws a RuntimeException on JRE versions prior to 1.4.0.
RuntimeException - when a NoSuchAlgorithmException is caught.private static MessageDigest getSha512Digest()
Throws a RuntimeException on JRE versions prior to 1.4.0.
RuntimeException - when a NoSuchAlgorithmException is caught.private static MessageDigest getShaDigest()
RuntimeException - when a NoSuchAlgorithmException is caught.public static byte[] md5(byte[] data)
byte[].
data - Data to digest
public static byte[] md5(InputStream data)
throws IOException
byte[].
data - Data to digest
IOException - On error reading from the streampublic static byte[] md5(String data)
byte[].
data - Data to digest
public static String md5Hex(byte[] data)
data - Data to digest
public static String md5Hex(InputStream data)
throws IOException
data - Data to digest
IOException - On error reading from the streampublic static String md5Hex(String data)
data - Data to digest
public static byte[] sha(byte[] data)
byte[].
data - Data to digest
public static byte[] sha(InputStream data)
throws IOException
byte[].
data - Data to digest
IOException - On error reading from the streampublic static byte[] sha(String data)
byte[].
data - Data to digest
public static byte[] sha256(byte[] data)
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static byte[] sha256(InputStream data)
throws IOException
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
IOException - On error reading from the streampublic static byte[] sha256(String data)
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static String sha256Hex(byte[] data)
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static String sha256Hex(InputStream data)
throws IOException
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
IOException - On error reading from the streampublic static String sha256Hex(String data)
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static byte[] sha384(byte[] data)
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static byte[] sha384(InputStream data)
throws IOException
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
IOException - On error reading from the streampublic static byte[] sha384(String data)
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static String sha384Hex(byte[] data)
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static String sha384Hex(InputStream data)
throws IOException
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
IOException - On error reading from the streampublic static String sha384Hex(String data)
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static byte[] sha512(byte[] data)
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static byte[] sha512(InputStream data)
throws IOException
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
IOException - On error reading from the streampublic static byte[] sha512(String data)
byte[].
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static String sha512Hex(byte[] data)
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static String sha512Hex(InputStream data)
throws IOException
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
IOException - On error reading from the streampublic static String sha512Hex(String data)
Throws a RuntimeException on JRE versions prior to 1.4.0.
data - Data to digest
public static String shaHex(byte[] data)
data - Data to digest
public static String shaHex(InputStream data)
throws IOException
data - Data to digest
IOException - On error reading from the streampublic static String shaHex(String data)
data - Data to digest
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||