Package opennlp.tools.util
Class Checksums
java.lang.Object
opennlp.tools.util.Checksums
Computes and validates the hex-encoded file digests that downloads are verified
against.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringThe SHA-256 algorithm name.(package private) static final intThe number of hex digits in a SHA-256 digest.(package private) static final StringThe SHA-512 algorithm name.(package private) static final intThe number of hex digits in a SHA-512 digest. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
SHA_256
The SHA-256 algorithm name.- See Also:
-
SHA_512
The SHA-512 algorithm name.- See Also:
-
SHA_256_HEX_LENGTH
static final int SHA_256_HEX_LENGTHThe number of hex digits in a SHA-256 digest.- See Also:
-
SHA_512_HEX_LENGTH
static final int SHA_512_HEX_LENGTHThe number of hex digits in a SHA-512 digest.- See Also:
-
-
Constructor Details
-
Checksums
private Checksums()Prevents construction of this utility class.
-
-
Method Details
-
hexDigest
Computes the digest of a file's bytes.- Parameters:
file- The file to digest.algorithm- TheMessageDigestalgorithm name, for exampleSHA_512.- Returns:
- The digest as lowercase hex digits. Not
null. - Throws:
IOException- Thrown if the file cannot be read or the algorithm is not available in this runtime.
-
isHexDigest
Checks that a string is a hex digest of the given length, in either letter case.- Parameters:
value- The string to inspect.length- The required number of hex digits.- Returns:
trueifvaluehaslengthcharacters and each is a hex digit.
-