public final class ChecksumCalculator extends Object
Modifier and Type | Field and Description |
---|---|
static String |
MD5
Defines the MD5 checksum algorithm
|
static String |
SHA1
Defines the SHA1 checksum algorithm
|
Constructor and Description |
---|
ChecksumCalculator() |
Modifier and Type | Method and Description |
---|---|
static String |
calculateMd5(byte[] msg)
Generate an MD5 for a byte array.
|
static String |
calculateMd5(File src)
Calculate MD5 for a file.
|
static String |
calculateMd5(InputStream instream)
Calculates an MD5 digest on an InputStream, throwing away the data itself.
|
static String |
calculateSha1(File src)
Calculate the SHA-1 DIGEST for a file.
|
static String |
calculateSha1(InputStream instream)
Calculates an SHA-1 digest on an InputStream, throwing away the data itself.
|
static byte[] |
digestFile(File src,
String digestAlgorithm) |
static byte[] |
digestInputStream(InputStream instream,
String algorithm) |
static MessageDigest |
getMessageDigest(String algorithm)
Get a MessageDigest for a specific algorithm.
|
static String |
toHex(byte[] ba)
Converts a byte array to a hexstring.
|
public static final String MD5
public static final String SHA1
public ChecksumCalculator()
public static String calculateMd5(File src)
src
- The file to calculate MD5 for.public static String calculateSha1(File src)
src
- The file to calculate SHA-1 for.public static String calculateMd5(InputStream instream)
instream
- An InputStream
to calculate the MD5 digest on. The contents of the stream will be
consumed by this call, but the stream will not be closed.public static String calculateSha1(InputStream instream)
instream
- An InputStream
to calculate the SHA-1 digest on. The contents of the stream will be
consumed by this call, but the stream will not be closed.public static String calculateMd5(byte[] msg)
msg
- The given bytearraypublic static String toHex(byte[] ba)
ba
- the bytearray to be convertedpublic static byte[] digestFile(File src, String digestAlgorithm)
public static byte[] digestInputStream(InputStream instream, String algorithm)
public static MessageDigest getMessageDigest(String algorithm)
algorithm
- a specific MessageDigest algorithm.Copyright © 2005–2016 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.