public class ChecksumUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ChecksumUtil.Algorithm
This class encapsulates the valid values for checksum algorithms.
|
Constructor and Description |
---|
ChecksumUtil(ChecksumUtil.Algorithm alg) |
Modifier and Type | Method and Description |
---|---|
static String |
checksumBytesToString(byte[] digestBytes)
Converts a message digest byte array into a String based
on the hex values appearing in the array.
|
static String |
convertToBase64Encoding(String hexEncodedChecksum)
Converts a hex-encoded checksum (like that produced by the getChecksum
and generateChecksum methods of this class) to a base64-encoded checksum
|
String |
generateChecksum(File file) |
String |
generateChecksum(InputStream inStream)
This method generates checksum of content in arg stream.
|
String |
generateChecksum(String string)
This method generates the checksum of a String and returns a hex-encoded
String as the checksum value
|
String |
generateChecksumBase64(String string)
This method generates the checksum of a String and returns a
base64-encoded String as the checksum value
|
static String |
getChecksum(DigestInputStream digestStream)
Determines the checksum value of a DigestInputStream's underlying
stream after the stream has been read.
|
static byte[] |
getChecksumBytes(DigestInputStream digestStream)
Determines the checksum value of a DigestInputStream's underlying
stream after the stream has been read.
|
static byte[] |
hexStringToByteArray(String s) |
static DigestInputStream |
wrapStream(InputStream inStream,
ChecksumUtil.Algorithm algorithm)
Wraps an InputStream with a DigestInputStream in order to compute
a checksum as the stream is being read.
|
public ChecksumUtil(ChecksumUtil.Algorithm alg)
public String generateChecksum(File file) throws IOException
IOException
public String generateChecksum(InputStream inStream)
inStream
- Content used as target of checksum.public String generateChecksum(String string)
string
- Content used as target of checksum.public String generateChecksumBase64(String string)
string
- Content used as target of checksum.public static DigestInputStream wrapStream(InputStream inStream, ChecksumUtil.Algorithm algorithm)
inStream
- The stream to wrapalgorithm
- The algorithm used to compute the digestpublic static String getChecksum(DigestInputStream digestStream)
digestStream
- public static byte[] getChecksumBytes(DigestInputStream digestStream)
digestStream
- public static String checksumBytesToString(byte[] digestBytes)
public static byte[] hexStringToByteArray(String s)
public static String convertToBase64Encoding(String hexEncodedChecksum)
hexEncodedChecksum
- hex-encoded checksumCopyright © 2009–2014 DuraSpace. All rights reserved.