import java.io.*;
import java.security.*;

public class AqIntegrityCheck 
{
    private static long hash(byte[] b) {
        long result = 0;
        for (int i=0; i<b.length; i++) {
            result += (int)b[i];
        }
        result += 42;
        return result;
    }
    
    public static void integrityCheck()
    {
        /* Acquisition.app/Contents/Resources */
        File pwd = new File(System.getProperty("user.dir"));
        File mainApp = new File(new File(pwd.getParentFile(), "MacOS"), "Acquisition");
        
        try {

            byte[] contents = new byte[(int)mainApp.length()];
            (new FileInputStream(mainApp)).read(contents);

            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] digest = md.digest(contents);
            
            long hc = AqIntegrityCheck.hash(contents);
            long hd = AqIntegrityCheck.hash(digest);
            
            boolean a = false;
            boolean b = false;
            
            if (a) {
                System.err.println(hc);
                System.err.println(hd);
            }
            
            if (b) {
                long xc = 9768463;
                long xd = 9;
                
                if (hc != xc || hd != xd) {
                    while (true) {
                        Thread.sleep(1000);
                    }
                }
            }
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}