public String generateSHA1(String fileName) {
        int           n      = 0;
        byte[]        buffer = new byte[8192];
        MessageDigest digest;
        try {
            digest = MessageDigest.getInstance("SHA-1");
        } catch (NoSuchAlgorithmException e) {
            digest = null;
            e.printStackTrace();
        }
        InputStream fis;
        try {
            fis = new FileInputStream(fileName);
        } catch (FileNotFoundException e) {
            fis = null;
            e.printStackTrace();
        }
        while (n != -1) {
            try {
                n = fis.read(buffer);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (n > 0) {
                digest.update(buffer, 0, n);
            }
        }
        byte[] mdbytes = digest.digest();
        
        // Convert to hex format:
        StringBuffer sb = new StringBuffer("");
        for (int i = 0; i < mdbytes.length; i++) {
            sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
        }
        
        return sb.toString();
    }