Code example for MessageDigest

Methods: clonedigest

	 * @tests 
    public void test_onZ() throws Exception { 
        // Test for method void 
        MessageDigest originalDigest = (MessageDigest) (digest.clone());
        MessageDigest noChangeDigest = (MessageDigest) (digest.clone());
        DigestInputStream dis = new DigestInputStream(inStream, noChangeDigest);
        // turn off processing 
        // read some data 
        int c =;
        assertEquals('T', c);
        // make sure the digest for the part where it was off has not 
        // changed 
        assertTrue("MessageDigest changed even though processing was off",
                MessageDigest.isEqual(noChangeDigest.digest(), originalDigest
        MessageDigest changeDigest = (MessageDigest) (digest.clone());
        dis = new DigestInputStream(inStream, digest);
        // turn on processing 
        c =;
        assertEquals('h', c);
        // make sure the digest has changed 
        assertTrue("MessageDigest did not change with processing on",
                !MessageDigest.isEqual(digest.digest(), changeDigest.digest()));
	 * @tests