Package org.apache.sshd.common.digest
Class DigestUtils
- java.lang.Object
-
- org.apache.sshd.common.digest.DigestUtils
-
public final class DigestUtils extends Object
- Author:
- Apache MINA SSHD Project
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancheckSupported(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 StringgetFingerPrint(Digest d, byte... buf)static StringgetFingerPrint(Digest d, byte[] buf, int offset, int len)static StringgetFingerPrint(Digest d, String s)static StringgetFingerPrint(Digest d, String s, Charset charset)static StringgetFingerPrint(Factory<? extends Digest> f, byte... buf)static StringgetFingerPrint(Factory<? extends Digest> f, byte[] buf, int offset, int len)static StringgetFingerPrint(Factory<? extends Digest> f, String s)static StringgetFingerPrint(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)
-
-
-
Method Detail
-
checkSupported
public static boolean checkSupported(String algorithm)
- Parameters:
algorithm- The digest algorithm - nevernull/empty- Returns:
trueif this digest algorithm is supported- See Also:
SecurityUtils.getMessageDigest(String)
-
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- TheComparatorto use to compare algorithm namesdigests- The factories to check - ignored ifnull/empty- Returns:
- The first
DigestFactorywhose algorithm matches the required one according to the comparator -nullif 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- TheComparatorto use to compare algorithm namesfactories- The factories to check - ignored ifnull/empty- Returns:
- The first
DigestFactorywhose algorithm matches the required one according to the comparator -nullif no match found
-
getFingerPrint
public static String getFingerPrint(Factory<? extends Digest> f, String s) throws Exception
- Parameters:
f- TheFactoryto create theDigestto uses- TheStringto digest - ignored ifnull/empty, otherwise its UTF-8 representation is used as input for the fingerprint- Returns:
- The fingerprint -
nullifnull/empty input - Throws:
Exception- If failed to calculate the digest- See Also:
getFingerPrint(Digest, String, Charset)
-
getFingerPrint
public static String getFingerPrint(Factory<? extends Digest> f, String s, Charset charset) throws Exception
- Parameters:
f- TheFactoryto create theDigestto uses- TheStringto digest - ignored ifnull/emptycharset- TheCharsetto use in order to convert the string to its byte representation to use as input for the fingerprint- Returns:
- The fingerprint -
nullifnull/empty input - Throws:
Exception- If failed to calculate the digest
-
getFingerPrint
public static String getFingerPrint(Digest d, String s) throws Exception
- Parameters:
d- TheDigestto uses- TheStringto digest - ignored ifnull/empty, otherwise its UTF-8 representation is used as input for the fingerprint- Returns:
- The fingerprint -
nullifnull/empty input - Throws:
Exception- If failed to calculate the digest- See Also:
getFingerPrint(Digest, String, Charset)
-
getFingerPrint
public static String getFingerPrint(Digest d, String s, Charset charset) throws Exception
- Parameters:
d- TheDigestto uses- TheStringto digest - ignored ifnull/emptycharset- TheCharsetto use in order to convert the string to its byte representation to use as input for the fingerprint- Returns:
- The fingerprint -
nullifnull/empty input - Throws:
Exception- If failed to calculate the digest
-
getFingerPrint
public static String getFingerPrint(Factory<? extends Digest> f, byte... buf) throws Exception
- Parameters:
f- TheFactoryto create theDigestto usebuf- The data buffer to be fingerprint-ed- Returns:
- The fingerprint -
nullif empty data buffer - Throws:
Exception- If failed to calculate the fingerprint- See Also:
getFingerPrint(Factory, byte[], int, int)
-
getFingerPrint
public static String getFingerPrint(Factory<? extends Digest> f, byte[] buf, int offset, int len) throws Exception
- Parameters:
f- TheFactoryto create theDigestto 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 -
nullif non-positive length - Throws:
Exception- If failed to calculate the fingerprint
-
getFingerPrint
public static String getFingerPrint(Digest d, byte... buf) throws Exception
- Parameters:
d- TheDigestto usebuf- The data buffer to be fingerprint-ed- Returns:
- The fingerprint -
nullif empty data buffer - Throws:
Exception- If failed to calculate the fingerprint- See Also:
getFingerPrint(Digest, byte[], int, int)
-
getFingerPrint
public static String getFingerPrint(Digest d, byte[] buf, int offset, int len) throws Exception
- Parameters:
d- TheDigestto 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 -
nullif non-positive length - Throws:
Exception- If failed to calculate the fingerprint- See Also:
getRawFingerprint(Digest, byte[], int, int)
-
getRawFingerprint
public static byte[] getRawFingerprint(Digest d, byte... buf) throws Exception
- Throws:
Exception
-
-