public final class DigestUtils
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
DigestUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkSupported(java.lang.String algorithm) |
static <D extends Digest> |
findDigestByAlgorithm(java.lang.String algo,
java.util.Comparator<? super java.lang.String> comp,
java.util.Collection<? extends D> digests) |
static <F extends DigestFactory> |
findFactoryByAlgorithm(java.lang.String algo,
java.util.Comparator<? super java.lang.String> comp,
java.util.Collection<? extends F> factories) |
static java.lang.String |
getFingerPrint(Digest d,
byte... buf) |
static java.lang.String |
getFingerPrint(Digest d,
byte[] buf,
int offset,
int len) |
static java.lang.String |
getFingerPrint(Digest d,
java.lang.String s) |
static java.lang.String |
getFingerPrint(Digest d,
java.lang.String s,
java.nio.charset.Charset charset) |
static java.lang.String |
getFingerPrint(Factory<? extends Digest> f,
byte... buf) |
static java.lang.String |
getFingerPrint(Factory<? extends Digest> f,
byte[] buf,
int offset,
int len) |
static java.lang.String |
getFingerPrint(Factory<? extends Digest> f,
java.lang.String s) |
static java.lang.String |
getFingerPrint(Factory<? extends Digest> f,
java.lang.String s,
java.nio.charset.Charset charset) |
static byte[] |
getRawFingerprint(Digest d,
byte... buf) |
static byte[] |
getRawFingerprint(Digest d,
byte[] buf,
int offset,
int len) |
public static boolean checkSupported(java.lang.String algorithm)
algorithm
- The digest algorithm - never null
/emptytrue
if this digest algorithm is supportedSecurityUtils.getMessageDigest(String)
public static <D extends Digest> D findDigestByAlgorithm(java.lang.String algo, java.util.Comparator<? super java.lang.String> comp, java.util.Collection<? extends D> digests)
D
- The generic type of digest factoryalgo
- The required algorithm name - ignored if null
/emptycomp
- The Comparator
to use to compare algorithm namesdigests
- The factories to check - ignored if null
/emptyDigestFactory
whose algorithm matches the required one
according to the comparator - null
if no match foundpublic static <F extends DigestFactory> F findFactoryByAlgorithm(java.lang.String algo, java.util.Comparator<? super java.lang.String> comp, java.util.Collection<? extends F> factories)
F
- The generic type of digest factoryalgo
- The required algorithm name - ignored if null
/emptycomp
- The Comparator
to use to compare algorithm namesfactories
- The factories to check - ignored if null
/emptyDigestFactory
whose algorithm matches the required one
according to the comparator - null
if no match foundpublic static java.lang.String getFingerPrint(Factory<? extends Digest> f, java.lang.String s) throws java.lang.Exception
f
- The Factory
to create the Digest
to uses
- The String
to digest - ignored if null
/empty,
otherwise its UTF-8 representation is used as input for the fingerprintnull
if null
/empty inputjava.lang.Exception
- If failed to calculate the digestgetFingerPrint(Digest, String, Charset)
public static java.lang.String getFingerPrint(Factory<? extends Digest> f, java.lang.String s, java.nio.charset.Charset charset) throws java.lang.Exception
f
- The Factory
to create the Digest
to uses
- The String
to digest - ignored if null
/emptycharset
- The Charset
to use in order to convert the
string to its byte representation to use as input for the fingerprintnull
if null
/empty inputjava.lang.Exception
- If failed to calculate the digestpublic static java.lang.String getFingerPrint(Digest d, java.lang.String s) throws java.lang.Exception
d
- The Digest
to uses
- The String
to digest - ignored if null
/empty,
otherwise its UTF-8 representation is used as input for the fingerprintnull
if null
/empty inputjava.lang.Exception
- If failed to calculate the digestgetFingerPrint(Digest, String, Charset)
public static java.lang.String getFingerPrint(Digest d, java.lang.String s, java.nio.charset.Charset charset) throws java.lang.Exception
d
- The Digest
to uses
- The String
to digest - ignored if null
/emptycharset
- The Charset
to use in order to convert the
string to its byte representation to use as input for the fingerprintnull
if null
/empty inputjava.lang.Exception
- If failed to calculate the digestpublic static java.lang.String getFingerPrint(Factory<? extends Digest> f, byte... buf) throws java.lang.Exception
f
- The Factory
to create the Digest
to usebuf
- The data buffer to be fingerprint-ednull
if empty data bufferjava.lang.Exception
- If failed to calculate the fingerprintgetFingerPrint(Factory, byte[], int, int)
public static java.lang.String getFingerPrint(Factory<? extends Digest> f, byte[] buf, int offset, int len) throws java.lang.Exception
f
- The Factory
to create the Digest
to usebuf
- The data buffer to be fingerprint-edoffset
- The offset of the data in the bufferlen
- The length of data - ignored if non-positivenull
if non-positive lengthjava.lang.Exception
- If failed to calculate the fingerprintpublic static java.lang.String getFingerPrint(Digest d, byte... buf) throws java.lang.Exception
d
- The Digest
to usebuf
- The data buffer to be fingerprint-ednull
if empty data bufferjava.lang.Exception
- If failed to calculate the fingerprintgetFingerPrint(Digest, byte[], int, int)
public static java.lang.String getFingerPrint(Digest d, byte[] buf, int offset, int len) throws java.lang.Exception
d
- The Digest
to usebuf
- The data buffer to be fingerprint-edoffset
- The offset of the data in the bufferlen
- The length of data - ignored if non-positivenull
if non-positive lengthjava.lang.Exception
- If failed to calculate the fingerprintgetRawFingerprint(Digest, byte[], int, int)
public static byte[] getRawFingerprint(Digest d, byte... buf) throws java.lang.Exception
java.lang.Exception
public static byte[] getRawFingerprint(Digest d, byte[] buf, int offset, int len) throws java.lang.Exception
java.lang.Exception