Interface HashUtils
- All Known Implementing Classes:
HashUtilsImpl
public interface HashUtils
-
Method Summary
Modifier and TypeMethodDescriptioncreateChecksumFile(File file, HashAlgorithm algorithm) Creates a checksum file for a given file.hash(File file, HashAlgorithm algorithm) Get the hash for a given file.booleanisChecksumFile(File file) Test whether a givenFileis a file that is considered a checksum file based on its extension ending withHashAlgorithm.MD5,HashAlgorithm.SHA1,HashAlgorithm.SHA256orHashAlgorithm.SHA512.booleanisSignatureFile(File file) Test whether a givenFileis a file that is considered a signature file with .asc extension
-
Method Details
-
hash
Get the hash for a given file.- Parameters:
file- -Filealgorithm- -HashAlgorithm- Returns:
- String or null if the file didn't exist or issues occurred reading it.
-
createChecksumFile
Creates a checksum file for a given file. The hash file will be created alongside the givenfilein the same parent directory. Example the the file /test/1.0.jar, after calling this method with, for exampleHashAlgorithm.SHA512, have alongside itself the file /test/1.0.jar.sha512- Parameters:
file- -Filealgorithm- -HashAlgorithm- Returns:
- File - the
Filewith the hash for the givenfile, or null if unable to create it.
-
isChecksumFile
Test whether a givenFileis a file that is considered a checksum file based on its extension ending withHashAlgorithm.MD5,HashAlgorithm.SHA1,HashAlgorithm.SHA256orHashAlgorithm.SHA512.- Parameters:
file- -File- Returns:
- true if the given file is considered a checksum file.
-
isSignatureFile
Test whether a givenFileis a file that is considered a signature file with .asc extension- Parameters:
file- -File- Returns:
- true if the given file is considered a signature file
-