BELUtilities { public static String computeHashSHA256(final InputStream input) throws IOException { if (input == null) { throw new InvalidArgument("input", input); } MessageDigest sha256; try { sha256 = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { throw new MissingAlgorithmException(SHA_256, e); } final DigestInputStream dis = new DigestInputStream(input, sha256); while (dis.read() != -1) {} byte[] mdbytes = sha256.digest(); 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(); } private  BELUtilities(); static HashSet<E> asHashSet(final Collection<E> c); static String asPath(final String... strings); static String asPath(final String directory, final String filename); static void closeQuietly(Closeable closeable); static long computeHash64(CharSequence cs); static String computeHashSHA256(final InputStream input); static int[] concatArrays(int[] a, int[] b); static HashMap<K, V> constrainedHashMap(final int s); static HashSet<T> constrainedHashSet(final int s); static long copy(final InputStream input, final OutputStream output); static void copyFile(final File src, final File dest); static void createDirectories(final String directory); static void createDirectory(final String directory); static boolean deleteDirectory(final File dir); static boolean deleteDirectoryContents(final File dir); static Set<Map.Entry<K, V>> entries(Map<K, V> m); static boolean equals(Object o1, Object o2); static Throwable getFirstCause(Throwable t); static String getFirstMessage(Throwable t); static String getFirstStacktrace(Throwable t); static int getPID(); static long getThreadID(); static boolean hasItems(final Collection<?> c); static boolean hasItems(final Map<K, V> m); static boolean hasItems(final T[] t); static boolean hasLength(final String s); static T[] index(Class<T> cls, Map<Integer, T> map); static void mapfx(Map<K, V> map, MapFunction<K, V> fx); static T search(Iterable<T> iter, SearchFunction<T> fx); static boolean isAlphanumeric(String s); static boolean isNumeric(String s); static boolean isBELDocument(final File file); static boolean isBELDocument(final String path); static boolean isBELScript(final File file); static boolean isBELScript(final String path); static boolean isXBEL(final File file); static boolean isXBEL(final String path); static String join(Collection<String> strings, String separator); static boolean noItems(final Collection<?> c); static boolean noItems(final Map<K, V> m); static boolean noItems(final T[] t); static boolean noLength(final String s); static boolean noLength(final String... strings); static boolean noNulls(final Object... objects); static boolean nulls(final Object... objects); static HashMap<K, V> optimizedHashMap(final int s,
            final float lf); static HashSet<T> optimizedHashSet(final int s, final float lf); static boolean readable(final File file); static ArrayList<T> sizedArrayList(final int size); static HashMap<K, V> sizedHashMap(final int size); static HashSet<T> sizedHashSet(final int size); static boolean substringEquals(final String s1,
            final int fromIndex1, final int toIndex1,
            final String s2, final int fromIndex2, final int toIndex2); static String timeFormat(final long milliseconds); @SuppressWarnings("unchecked") static List<T> typedList(List<?> objects, Class<T> t); static int ephemeralPort(); static boolean portAvailable(int port); static String quoteParameter(final String param);  }
@Test public void testSHA256Hash() throws IOException { final String checksum = "e96530c04be684f1a468a98d8ab8174bba704503fb6" + "9e1ccb5376bfe3f8390c6"; final InputStream input = BELUtilitiesTest.class .getResourceAsStream("test.belns"); assertEquals(checksum, computeHashSHA256(input)); }