public static Sha1Hash forFile (File file) throws IOException {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA1");
        } catch (NoSuchAlgorithmException e) {
            // If the SHA1 algorithm doesn't exist, returns null
            return null;
        }

        FileInputStream fis = null;

        try {
            fis = new FileInputStream(file);
            byte[] buffer = new byte[65536];
            while (fis.available() > 0) {
                int num = fis.read(buffer);
                md.update(buffer, 0, num);
            }
        } finally {
            if (fis != null)
                fis.close();
        }

        return new Sha1Hash(md.digest());
    }