public final class ChecksumExtensions extends Object
ChecksumExtensions is a utility class for computing checksum from files and
byte arrays.| Modifier and Type | Field and Description |
|---|---|
protected static org.apache.log4j.Logger |
LOGGER
The LOGGER.
|
static String |
REGEX_VALIDATION_MD5
The constant REGEX_VALIDATION_MD5.
|
static String |
REGEX_VALIDATION_SHA1
The constant REGEX_VALIDATION_SHA1.
|
static String |
REGEX_VALIDATION_SHA512
The constant REGEX_VALIDATION_SHA512.
|
| Constructor and Description |
|---|
ChecksumExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static String |
getChecksum(byte[] bytes,
de.alpharogroup.crypto.algorithm.Algorithm algorithm)
Gets the checksum from the given byte array with an instance of.
|
static String |
getChecksum(Byte[] bytes,
de.alpharogroup.crypto.algorithm.Algorithm algorithm)
Gets the checksum from the given byte array with an instance of.
|
static String |
getChecksum(byte[] bytes,
String algorithm)
Gets the checksum from the given byte array with an instance of.
|
static String |
getChecksum(Byte[] bytes,
String algorithm)
Gets the checksum from the given byte array with an instance of.
|
static String |
getChecksum(File file,
de.alpharogroup.crypto.algorithm.Algorithm algorithm)
Gets the checksum from the given file with an instance of the given algorithm.
|
static long |
getChecksum(File file,
boolean crc)
Gets the checksum from the given file.
|
static String |
getChecksum(File file,
String algorithm)
Gets the checksum from the given file with an instance of the given algorithm.
|
static long |
getCheckSumAdler32(byte[] bytes)
Gets the checksum from the given byte array with an instance of.
|
static long |
getCheckSumAdler32(File file)
Gets the checksum from the given file with an instance of.
|
static long |
getCheckSumCRC32(byte[] bytes)
Gets the checksum from the given byte array with an instance of.
|
static long |
getCheckSumCRC32(File file)
Gets the checksum from the given file with an instance of.
|
static String |
getChecksumQuietly(byte[] bytes,
de.alpharogroup.crypto.algorithm.Algorithm algorithm)
Deprecated.
use instead the same name method in the class
ChecksumQuietlyExtensions.
Note: will be removed in the next minor release. |
static String |
getChecksumQuietly(byte[] bytes,
String algorithm)
Deprecated.
use instead the same name method in the class
ChecksumQuietlyExtensions.
Note: will be removed in the next minor release. |
static String |
getChecksumQuietly(Byte[] bytes,
String algorithm)
Deprecated.
use instead the same name method in the class
ChecksumQuietlyExtensions.
Note: will be removed in the next minor release. |
static String |
getChecksumQuietly(File file,
de.alpharogroup.crypto.algorithm.Algorithm algorithm)
Deprecated.
use instead the same name method in the class
ChecksumQuietlyExtensions.
Note: will be removed in the next minor release. |
static boolean |
matchesMD5(String value)
Checks if the given value matches a MD5 value pattern.
|
static boolean |
matchesSHA1(String value)
Checks if the given value matches a SHA1 value pattern.
|
static boolean |
matchesSHA512(String value)
Checks if the given value matches a SHA512 value pattern.
|
protected static final org.apache.log4j.Logger LOGGER
public static final String REGEX_VALIDATION_SHA1
public static final String REGEX_VALIDATION_MD5
public static final String REGEX_VALIDATION_SHA512
public static String getChecksum(byte[] bytes, de.alpharogroup.crypto.algorithm.Algorithm algorithm) throws NoSuchAlgorithmException
bytes - the byte array.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".NoSuchAlgorithmException - Is thrown if the algorithm is not supported or does not exists.
MessageDigest object.public static String getChecksum(byte[] bytes, String algorithm) throws NoSuchAlgorithmException
bytes - the byte array.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".NoSuchAlgorithmException - Is thrown if the algorithm is not supported or does not exists.
MessageDigest object.public static String getChecksum(Byte[] bytes, de.alpharogroup.crypto.algorithm.Algorithm algorithm) throws NoSuchAlgorithmException
bytes - the Byte object array.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".NoSuchAlgorithmException - Is thrown if the algorithm is not supported or does not exists.
MessageDigest object.public static String getChecksum(Byte[] bytes, String algorithm) throws NoSuchAlgorithmException
bytes - the Byte object array.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".NoSuchAlgorithmException - Is thrown if the algorithm is not supported or does not exists.
MessageDigest object.public static String getChecksum(File file, de.alpharogroup.crypto.algorithm.Algorithm algorithm) throws NoSuchAlgorithmException, IOException
file - the file.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".NoSuchAlgorithmException - Is thrown if the algorithm is not supported or does not exists.
MessageDigest object.IOException - Signals that an I/O exception has occurred.public static long getChecksum(File file, boolean crc) throws FileNotFoundException, IOException
java.util.zip.CRC32 otherwise with an instance
of java.util.zip.Adler32.file - The file The file from what to get the checksum.crc - The crc If the flag crc is true than the CheckedInputStream is constructed with an
instance of CRC32 object otherwise it is constructed with an
instance ofFileNotFoundException - Is thrown if the file is not found.IOException - Signals that an I/O exception has occurred. CRC32 object
otherwise it is constructed with an instance of Adler32
object. Adler32 object.public static String getChecksum(File file, String algorithm) throws NoSuchAlgorithmException, IOException
file - the file.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".NoSuchAlgorithmException - Is thrown if the algorithm is not supported or does not exists.
MessageDigest object.IOException - Signals that an I/O exception has occurred.public static long getCheckSumAdler32(byte[] bytes)
bytes - The byte array.Adler32 object.public static long getCheckSumAdler32(File file) throws IOException
file - The file.Adler32 object.IOException - Signals that an I/O exception has occurred.public static long getCheckSumCRC32(byte[] bytes)
bytes - The byte array.CRC32 object.public static long getCheckSumCRC32(File file) throws IOException
file - The file.CRC32 object.IOException - Signals that an I/O exception has occurred.public static String getChecksumQuietly(byte[] bytes, de.alpharogroup.crypto.algorithm.Algorithm algorithm)
ChecksumQuietlyExtensions.
bytes - the byte array.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".public static String getChecksumQuietly(byte[] bytes, String algorithm)
ChecksumQuietlyExtensions.
bytes - the byte array.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".public static String getChecksumQuietly(Byte[] bytes, String algorithm)
ChecksumQuietlyExtensions.
bytes - the Byte object array.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".public static String getChecksumQuietly(File file, de.alpharogroup.crypto.algorithm.Algorithm algorithm)
ChecksumQuietlyExtensions.
file - the file.algorithm - the algorithm to get the checksum. This could be for instance "MD4", "MD5",
"SHA-1", "SHA-256", "SHA-384" or "SHA-512".MessageDigest object.public static boolean matchesMD5(String value)
value - the valuepublic static boolean matchesSHA1(String value)
value - the valuepublic static boolean matchesSHA512(String value)
value - the valueCopyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.