public final class Checksum extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getChecksum(String algorithm,
File file)
Creates the cryptographic checksum of a given file using the specified algorithm.
|
static String |
getHex(byte[] raw)
Converts a byte array into a hex string.
|
static String |
getMD5Checksum(File file)
Calculates the MD5 checksum of a specified file.
|
static String |
getSHA1Checksum(File file)
Calculates the SHA1 checksum of a specified file.
|
public static byte[] getChecksum(String algorithm, File file) throws NoSuchAlgorithmException, IOException
Creates the cryptographic checksum of a given file using the specified algorithm.
algorithm - the algorithm to use to calculate the checksumfile - the file to calculate the checksum forIOException - when the file does not existNoSuchAlgorithmException - when an algorithm is specified that does not existpublic static String getMD5Checksum(File file) throws IOException, NoSuchAlgorithmException
file - the file to generate the MD5 checksumIOException - when the file passed in does not existNoSuchAlgorithmException - when the MD5 algorithm is not availablepublic static String getSHA1Checksum(File file) throws IOException, NoSuchAlgorithmException
file - the file to generate the MD5 checksumIOException - when the file passed in does not existNoSuchAlgorithmException - when the SHA1 algorithm is not availablepublic static String getHex(byte[] raw)
Converts a byte array into a hex string.
This method was copied from http://www.rgagnon.com/javadetails/java-0596.html
raw - a byte arrayCopyright© 2012-15 Jeremy Long. All Rights Reserved.