public final class DigestUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
checkSupported(String algorithm) |
static <D extends Digest> |
findDigestByAlgorithm(String algo,
Comparator<? super String> comp,
Collection<? extends D> digests) |
static <F extends DigestFactory> |
findFactoryByAlgorithm(String algo,
Comparator<? super String> comp,
Collection<? extends F> factories) |
static String |
getFingerPrint(Digest d,
byte... buf) |
static String |
getFingerPrint(Digest d,
byte[] buf,
int offset,
int len) |
static String |
getFingerPrint(Digest d,
String s) |
static String |
getFingerPrint(Digest d,
String s,
Charset charset) |
static String |
getFingerPrint(Factory<? extends Digest> f,
byte... buf) |
static String |
getFingerPrint(Factory<? extends Digest> f,
byte[] buf,
int offset,
int len) |
static String |
getFingerPrint(Factory<? extends Digest> f,
String s) |
static String |
getFingerPrint(Factory<? extends Digest> f,
String s,
Charset charset) |
public static boolean checkSupported(String algorithm)
algorithm
- The digest algorithm - never null
/emptytrue
if this digest algorithm is supportedSecurityUtils.getMessageDigest(String)
public static <D extends Digest> D findDigestByAlgorithm(String algo, Comparator<? super String> comp, 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(String algo, Comparator<? super String> comp, 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 String getFingerPrint(Factory<? extends Digest> f, String s) throws 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 inputException
- If failed to calculate the digestgetFingerPrint(Digest, String, Charset)
public static String getFingerPrint(Factory<? extends Digest> f, String s, Charset charset) throws 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 inputException
- If failed to calculate the digestpublic static String getFingerPrint(Digest d, String s) throws 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 inputException
- If failed to calculate the digestgetFingerPrint(Digest, String, Charset)
public static String getFingerPrint(Digest d, String s, Charset charset) throws 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 inputException
- If failed to calculate the digestpublic static String getFingerPrint(Factory<? extends Digest> f, byte... buf) throws Exception
f
- The Factory
to create the Digest
to usebuf
- The data buffer to be fingerprint-ednull
if empty data bufferException
- If failed to calculate the fingerprintgetFingerPrint(Factory, byte[], int, int)
public static String getFingerPrint(Factory<? extends Digest> f, byte[] buf, int offset, int len) throws 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 lengthException
- If failed to calculate the fingerprintpublic static String getFingerPrint(Digest d, byte... buf) throws Exception
d
- The Digest
to usebuf
- The data buffer to be fingerprint-ednull
if empty data bufferException
- If failed to calculate the fingerprintgetFingerPrint(Digest, byte[], int, int)
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.