Top Constructors Methods
org.apache.sshd.common.digest

public final Class DigestUtils

extends Object
Class Inheritance
Imports
java.nio.charset.Charset, .StandardCharsets, java.security.MessageDigest, java.util.Base64, .Collection, .Comparator, .Objects, org.apache.sshd.common.Factory, org.apache.sshd.common.util.GenericUtils, .NumberUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.BufferUtils, org.apache.sshd.common.util.security.SecurityUtils

Author
Apache MINA SSHD Project

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if this digest algorithm is supported
checkSupported
(String
The digest algorithm - never null/empty
algorithm
)

public static <
The generic type of digest factory
D extends Digest
>
D

Returns:

The first DigestFactory whose algorithm matches the required one according to the comparator - null if no match found
findDigestByAlgorithm
(String
The required algorithm name - ignored if null/empty
algo
,
Comparator<? super String>
The Comparator to use to compare algorithm names
comp
,
Collection<? extends D>
The factories to check - ignored if null/empty
digests
)

public static <
The generic type of digest factory
F extends DigestFactory
>
F

Returns:

The first DigestFactory whose algorithm matches the required one according to the comparator - null if no match found
findFactoryByAlgorithm
(String
The required algorithm name - ignored if null/empty
algo
,
Comparator<? super String>
The Comparator to use to compare algorithm names
comp
,
Collection<? extends F>
The factories to check - ignored if null/empty
factories
)

public static String

Returns:

The fingerprint - null if null/empty input
getFingerPrint
(Factory<? extends Digest>
The Factory to create the Digest to use
f
,
String
The String to digest - ignored if null/empty, otherwise its UTF-8 representation is used as input for the fingerprint
s
)

public static String

Returns:

The fingerprint - null if null/empty input
getFingerPrint
(Factory<? extends Digest>
The Factory to create the Digest to use
f
,
String
The String to digest - ignored if null/empty
s
,
Charset
The Charset to use in order to convert the string to its byte representation to use as input for the fingerprint
charset
)

public static String

Returns:

The fingerprint - null if null/empty input
getFingerPrint
(Digest
The Digest to use
d
,
String
The String to digest - ignored if null/empty, otherwise its UTF-8 representation is used as input for the fingerprint
s
)

public static String

Returns:

The fingerprint - null if null/empty input
getFingerPrint
(Digest
The Digest to use
d
,
String
The String to digest - ignored if null/empty
s
,
Charset
The Charset to use in order to convert the string to its byte representation to use as input for the fingerprint
charset
)

public static String

Returns:

The fingerprint - null if empty data buffer
getFingerPrint
(Factory<? extends Digest>
The Factory to create the Digest to use
f
,
byte...
The data buffer to be fingerprint-ed
buf
)

public static String

Returns:

The fingerprint - null if non-positive length
getFingerPrint
(Factory<? extends Digest>
The Factory to create the Digest to use
f
,
byte[]
The data buffer to be fingerprint-ed
buf
,
int
The offset of the data in the buffer
offset
,
int
The length of data - ignored if non-positive
len
)

public static String

Returns:

The fingerprint - null if empty data buffer
getFingerPrint
(Digest
The Digest to use
d
,
byte...
The data buffer to be fingerprint-ed
buf
)

public static String

Returns:

The fingerprint - null if non-positive length
getFingerPrint
(Digest
The Digest to use
d
,
byte[]
The data buffer to be fingerprint-ed
buf
,
int
The offset of the data in the buffer
offset
,
int
The length of data - ignored if non-positive
len
)

public static byte[]
getRawFingerprint(Digest d, byte... buf)

public static byte[]
getRawFingerprint(Digest d, byte[] buf, int offset, int len)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DigestUtilsback to summary
private DigestUtils()

Method Detail

checkSupportedback to summary
public static boolean checkSupported(String algorithm)
Parameters
algorithm:String

The digest algorithm - never null/empty

Returns:boolean

true if this digest algorithm is supported

See Also
SecurityUtils#getMessageDigest(String)
findDigestByAlgorithmback to summary
public static <D extends Digest> D findDigestByAlgorithm(String algo, Comparator<? super String> comp, Collection<? extends D> digests)
Parameters
<D>
The generic type of digest factory
algo:String

The required algorithm name - ignored if null/empty

comp:Comparator<? super String>

The Comparator to use to compare algorithm names

digests:Collection<? extends D>

The factories to check - ignored if null/empty

Returns:D

The first DigestFactory whose algorithm matches the required one according to the comparator - null if no match found

findFactoryByAlgorithmback to summary
public static <F extends DigestFactory> F findFactoryByAlgorithm(String algo, Comparator<? super String> comp, Collection<? extends F> factories)
Parameters
<F>
The generic type of digest factory
algo:String

The required algorithm name - ignored if null/empty

comp:Comparator<? super String>

The Comparator to use to compare algorithm names

factories:Collection<? extends F>

The factories to check - ignored if null/empty

Returns:F

The first DigestFactory whose algorithm matches the required one according to the comparator - null if no match found

getFingerPrintback to summary
public static String getFingerPrint(Factory<? extends Digest> f, String s) throws Exception
Parameters
f:Factory<? extends Digest>

The Factory to create the Digest to use

s:String

The String to digest - ignored if null/empty, otherwise its UTF-8 representation is used as input for the fingerprint

Returns:String

The fingerprint - null if null/empty input

Exceptions
Exception:
If failed to calculate the digest
See Also
getFingerPrint(Digest, String, Charset)
getFingerPrintback to summary
public static String getFingerPrint(Factory<? extends Digest> f, String s, Charset charset) throws Exception
Parameters
f:Factory<? extends Digest>

The Factory to create the Digest to use

s:String

The String to digest - ignored if null/empty

charset:Charset

The Charset to use in order to convert the string to its byte representation to use as input for the fingerprint

Returns:String

The fingerprint - null if null/empty input

Exceptions
Exception:
If failed to calculate the digest
getFingerPrintback to summary
public static String getFingerPrint(Digest d, String s) throws Exception
Parameters
d:Digest

The Digest to use

s:String

The String to digest - ignored if null/empty, otherwise its UTF-8 representation is used as input for the fingerprint

Returns:String

The fingerprint - null if null/empty input

Exceptions
Exception:
If failed to calculate the digest
See Also
getFingerPrint(Digest, String, Charset)
getFingerPrintback to summary
public static String getFingerPrint(Digest d, String s, Charset charset) throws Exception
Parameters
d:Digest

The Digest to use

s:String

The String to digest - ignored if null/empty

charset:Charset

The Charset to use in order to convert the string to its byte representation to use as input for the fingerprint

Returns:String

The fingerprint - null if null/empty input

Exceptions
Exception:
If failed to calculate the digest
getFingerPrintback to summary
public static String getFingerPrint(Factory<? extends Digest> f, byte... buf) throws Exception
Parameters
f:Factory<? extends Digest>

The Factory to create the Digest to use

buf:byte[]

The data buffer to be fingerprint-ed

Returns:String

The fingerprint - null if empty data buffer

Exceptions
Exception:
If failed to calculate the fingerprint
See Also
getFingerPrint(Factory, byte[], int, int)
getFingerPrintback to summary
public static String getFingerPrint(Factory<? extends Digest> f, byte[] buf, int offset, int len) throws Exception
Parameters
f:Factory<? extends Digest>

The Factory to create the Digest to use

buf:byte[]

The data buffer to be fingerprint-ed

offset:int

The offset of the data in the buffer

len:int

The length of data - ignored if non-positive

Returns:String

The fingerprint - null if non-positive length

Exceptions
Exception:
If failed to calculate the fingerprint
getFingerPrintback to summary
public static String getFingerPrint(Digest d, byte... buf) throws Exception
Parameters
d:Digest

The Digest to use

buf:byte[]

The data buffer to be fingerprint-ed

Returns:String

The fingerprint - null if empty data buffer

Exceptions
Exception:
If failed to calculate the fingerprint
See Also
getFingerPrint(Digest, byte[], int, int)
getFingerPrintback to summary
public static String getFingerPrint(Digest d, byte[] buf, int offset, int len) throws Exception
Parameters
d:Digest

The Digest to use

buf:byte[]

The data buffer to be fingerprint-ed

offset:int

The offset of the data in the buffer

len:int

The length of data - ignored if non-positive

Returns:String

The fingerprint - null if non-positive length

Exceptions
Exception:
If failed to calculate the fingerprint
See Also
getRawFingerprint(Digest, byte[], int, int)
getRawFingerprintback to summary
public static byte[] getRawFingerprint(Digest d, byte... buf) throws Exception
getRawFingerprintback to summary
public static byte[] getRawFingerprint(Digest d, byte[] buf, int offset, int len) throws Exception