Digest { public static byte[] makeRand() throws NoSuchAlgorithmException { byte[] digest = null; byte[] r = new byte[HASH_SIZE_BYTES]; try { random.nextBytes(r); digest = digest(r); } finally { return digest(r); } }  static byte[] digest(byte[] input); static byte[] makeRand(); static final int HASH_SIZE_BITS; static final int HASH_SIZE_BYTES; static final String HASH_ID; }
@Test public void testMakeRand() throws NoSuchAlgorithmException { byte[] r = Digest.makeRand(); assertFalse("makeRand failed - hash of all zeros", Arrays.equals(r, Digest.digest(new byte[Digest.HASH_SIZE_BYTES]))); if (r.length != Digest.HASH_SIZE_BYTES) { fail("Digest of random number failed - wrong length."); } }