Package org.apache.sshd.common.digest
Class DigestUtils
java.lang.Object
org.apache.sshd.common.digest.DigestUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkSupported
(String algorithm) static <D extends Digest>
DfindDigestByAlgorithm
(String algo, Comparator<? super String> comp, Collection<? extends D> digests) static <F extends DigestFactory>
FfindFactoryByAlgorithm
(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) static byte[]
getRawFingerprint
(Digest d, byte... buf) static byte[]
getRawFingerprint
(Digest d, byte[] buf, int offset, int len)
-
Constructor Details
-
DigestUtils
private DigestUtils()
-
-
Method Details
-
checkSupported
- Parameters:
algorithm
- The digest algorithm - nevernull
/empty- Returns:
true
if this digest algorithm is supported- See Also:
-
findDigestByAlgorithm
public static <D extends Digest> D findDigestByAlgorithm(String algo, Comparator<? super String> comp, Collection<? extends D> digests) - Type Parameters:
D
- The generic type of digest factory- Parameters:
algo
- The required algorithm name - ignored ifnull
/emptycomp
- TheComparator
to use to compare algorithm namesdigests
- The factories to check - ignored ifnull
/empty- Returns:
- The first
DigestFactory
whose algorithm matches the required one according to the comparator -null
if no match found
-
findFactoryByAlgorithm
public static <F extends DigestFactory> F findFactoryByAlgorithm(String algo, Comparator<? super String> comp, Collection<? extends F> factories) - Type Parameters:
F
- The generic type of digest factory- Parameters:
algo
- The required algorithm name - ignored ifnull
/emptycomp
- TheComparator
to use to compare algorithm namesfactories
- The factories to check - ignored ifnull
/empty- Returns:
- The first
DigestFactory
whose algorithm matches the required one according to the comparator -null
if no match found
-
getFingerPrint
-
getFingerPrint
public static String getFingerPrint(Factory<? extends Digest> f, String s, Charset charset) throws Exception - Parameters:
f
- TheFactory
to create theDigest
to uses
- TheString
to digest - ignored ifnull
/emptycharset
- TheCharset
to use in order to convert the string to its byte representation to use as input for the fingerprint- Returns:
- The fingerprint -
null
ifnull
/empty input - Throws:
Exception
- If failed to calculate the digest
-
getFingerPrint
-
getFingerPrint
- Parameters:
d
- TheDigest
to uses
- TheString
to digest - ignored ifnull
/emptycharset
- TheCharset
to use in order to convert the string to its byte representation to use as input for the fingerprint- Returns:
- The fingerprint -
null
ifnull
/empty input - Throws:
Exception
- If failed to calculate the digest
-
getFingerPrint
-
getFingerPrint
public static String getFingerPrint(Factory<? extends Digest> f, byte[] buf, int offset, int len) throws Exception - Parameters:
f
- TheFactory
to create theDigest
to usebuf
- The data buffer to be fingerprint-edoffset
- The offset of the data in the bufferlen
- The length of data - ignored if non-positive- Returns:
- The fingerprint -
null
if non-positive length - Throws:
Exception
- If failed to calculate the fingerprint
-
getFingerPrint
-
getFingerPrint
-
getRawFingerprint
- Throws:
Exception
-
getRawFingerprint
- Throws:
Exception
-