Class DigestOfFile

java.lang.Object
org.compiere.utils.DigestOfFile

public class DigestOfFile extends Object
Author:
rlemeill, Michael Judd BF [ 2736817 ] - remove deprecated BASE64Encoder classes
  • Constructor Details

    • DigestOfFile

      public DigestOfFile(String algorithm) throws Exception
      Parameters:
      algorithm - ie MD5
      Throws:
      Exception
  • Method Details

    • digestAsByteArray

      public byte[] digestAsByteArray(File file) throws Exception
      Parameters:
      file - to hash
      Returns:
      hash
      Throws:
      Exception
    • digestAsByteArray

      public byte[] digestAsByteArray(byte[] input) throws Exception
      Throws:
      Exception
    • digestAsBase64

      public String digestAsBase64(File file) throws Exception
      Parameters:
      file -
      Returns:
      hash (base64 encoded)
      Throws:
      Exception
    • digestAsBase64

      public String digestAsBase64(byte[] input) throws Exception
      Parameters:
      input -
      Returns:
      hash (base64 encoded)
      Throws:
      Exception
    • digestAsHex

      public String digestAsHex(File file) throws Exception
      Parameters:
      file -
      Returns:
      hex encoded md5 string
      Throws:
      Exception
    • digestAsHex

      public String digestAsHex(byte[] input) throws Exception
      Parameters:
      input -
      Returns:
      hex encoded md5 string
      Throws:
      Exception
    • main

      public static void main(String[] args)
      Parameters:
      args - file
    • md5HashCompare

      public static boolean md5HashCompare(File file1, File file2)
      Parameters:
      file1 - first file to compare
      file2 - second file to compare
      Returns:
      true if files are identic false otherwise
    • getMD5Hash

      public static String getMD5Hash(File file)
      Parameters:
      file -
      Returns:
      md5 hash null if file is not found or other error
    • getMD5Hash

      public static String getMD5Hash(byte[] input)
      Get md5 hash from byte[]
      Parameters:
      input -
      Returns:
      mdg hash string