public class DigestUtils
extends java.lang.Object
MessageDigest
tasks. This
class is thread safe.Constructor and Description |
---|
DigestUtils() |
Modifier and Type | Method and Description |
---|---|
(package private) static java.security.MessageDigest |
getDigest(java.lang.String algorithm)
Returns a MessageDigest for the given
algorithm . |
private static java.security.MessageDigest |
getMd5Digest()
Returns an MD5 MessageDigest.
|
private static java.security.MessageDigest |
getShaDigest()
Returns an SHA digest.
|
static byte[] |
md5(byte[] data)
Calculates the MD5 digest and returns the value as a 16 element
byte[] . |
static byte[] |
md5(java.lang.String data)
Calculates the MD5 digest and returns the value as a 16 element
byte[] . |
static java.lang.String |
md5Hex(byte[] data)
Calculates the MD5 digest and returns the value as a 32 character
hex string.
|
static java.lang.String |
md5Hex(java.lang.String data)
Calculates the MD5 digest and returns the value as a 32 character
hex string.
|
static byte[] |
sha(byte[] data)
Calculates the SHA digest and returns the value as a
byte[] . |
static byte[] |
sha(java.lang.String data)
Calculates the SHA digest and returns the value as a
byte[] . |
static java.lang.String |
shaHex(byte[] data)
Calculates the SHA digest and returns the value as a hex string.
|
static java.lang.String |
shaHex(java.lang.String data)
Calculates the SHA digest and returns the value as a hex string.
|
static java.security.MessageDigest getDigest(java.lang.String algorithm)
algorithm
.algorithm
- The MessageDigest algorithm name.java.lang.RuntimeException
- when a NoSuchAlgorithmException
is caught,private static java.security.MessageDigest getMd5Digest()
java.lang.RuntimeException
- when a NoSuchAlgorithmException
is caught,private static java.security.MessageDigest getShaDigest()
java.lang.RuntimeException
- when a NoSuchAlgorithmException
is caught,public static byte[] md5(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] md5(java.lang.String data)
byte[]
.data
- Data to digestpublic static java.lang.String md5Hex(byte[] data)
data
- Data to digestpublic static java.lang.String md5Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha(java.lang.String data)
byte[]
.data
- Data to digestpublic static java.lang.String shaHex(byte[] data)
data
- Data to digestpublic static java.lang.String shaHex(java.lang.String data)
data
- Data to digestcommons-codec version 1.3 - Copyright © 2002-2004 - Apache Software Foundation