Class ChecksumUtils


  • public final class ChecksumUtils
    extends java.lang.Object
    A utility class to assist in the verification and generation of checksums.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ChecksumUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.Object> calc​(byte[] dataBytes, java.util.Collection<java.lang.String> algos)
      Deprecated.
      Use SPI checksum selector instead.
      static java.util.Map<java.lang.String,​java.lang.Object> calc​(java.io.File dataFile, java.util.Collection<java.lang.String> algos)
      Deprecated.
      Use SPI checksum selector instead.
      private static java.util.Map<java.lang.String,​java.lang.Object> calc​(java.io.InputStream data, java.util.Collection<java.lang.String> algos)  
      static byte[] fromHexString​(java.lang.String hexString)
      Creates a byte array out of hexadecimal representation of the specified bytes.
      static java.lang.String read​(java.io.File checksumFile)
      Deprecated.
      Use SPI FileProcessor to read and write checksum files.
      static java.lang.String toHexString​(byte[] bytes)
      Creates a hexadecimal representation of the specified bytes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChecksumUtils

        private ChecksumUtils()
    • Method Detail

      • read

        @Deprecated
        public static java.lang.String read​(java.io.File checksumFile)
                                     throws java.io.IOException
        Deprecated.
        Use SPI FileProcessor to read and write checksum files.
        Extracts the checksum from the specified file.
        Parameters:
        checksumFile - The path to the checksum file, must not be null.
        Returns:
        The checksum stored in the file, never null.
        Throws:
        java.io.IOException - If the checksum does not exist or could not be read for other reasons.
      • calc

        @Deprecated
        public static java.util.Map<java.lang.String,​java.lang.Object> calc​(java.io.File dataFile,
                                                                                  java.util.Collection<java.lang.String> algos)
                                                                           throws java.io.IOException
        Deprecated.
        Use SPI checksum selector instead.
        Calculates checksums for the specified file.
        Parameters:
        dataFile - The file for which to calculate checksums, must not be null.
        algos - The names of checksum algorithms (cf. MessageDigest.getInstance(String) to use, must not be null.
        Returns:
        The calculated checksums, indexed by algorithm name, or the exception that occurred while trying to calculate it, never null.
        Throws:
        java.io.IOException - If the data file could not be read.
      • calc

        @Deprecated
        public static java.util.Map<java.lang.String,​java.lang.Object> calc​(byte[] dataBytes,
                                                                                  java.util.Collection<java.lang.String> algos)
                                                                           throws java.io.IOException
        Deprecated.
        Use SPI checksum selector instead.
        Throws:
        java.io.IOException
      • calc

        private static java.util.Map<java.lang.String,​java.lang.Object> calc​(java.io.InputStream data,
                                                                                   java.util.Collection<java.lang.String> algos)
                                                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • toHexString

        public static java.lang.String toHexString​(byte[] bytes)
        Creates a hexadecimal representation of the specified bytes. Each byte is converted into a two-digit hex number and appended to the result with no separator between consecutive bytes.
        Parameters:
        bytes - The bytes to represent in hex notation, may be be null.
        Returns:
        The hexadecimal representation of the input or null if the input was null.
      • fromHexString

        public static byte[] fromHexString​(java.lang.String hexString)
        Creates a byte array out of hexadecimal representation of the specified bytes. If input string is null, null is returned. Input value must have even length (due hex encoding = 2 chars one byte).
        Parameters:
        hexString - The hexString to convert to byte array, may be null.
        Returns:
        The byte array of the input or null if the input was null.
        Since:
        1.8.0