2N/A * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved. 2N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2N/A * This code is free software; you can redistribute it and/or modify it 2N/A * under the terms of the GNU General Public License version 2 only, as 2N/A * published by the Free Software Foundation. Oracle designates this 2N/A * particular file as subject to the "Classpath" exception as provided 2N/A * by Oracle in the LICENSE file that accompanied this code. 2N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2N/A * version 2 for more details (a copy is included in the LICENSE file that 2N/A * accompanied this code). 2N/A * You should have received a copy of the GNU General Public License version 2N/A * 2 along with this work; if not, write to the Free Software Foundation, 2N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2N/A * or visit www.oracle.com if you need additional information or have any 2N/A * A transparent stream that updates the associated message digest using 2N/A * the bits going through the stream. 2N/A * <p>To complete the message digest computation, call one of the 2N/A * <code>digest</code> methods on the associated message 2N/A * digest after your calls to one of this digest ouput stream's 2N/A * {@link #write(int) write} methods. 2N/A * <p>It is possible to turn this stream on or off (see 2N/A * {@link #on(boolean) on}). When it is on, a call to one of the 2N/A * <code>write</code> methods results in 2N/A * an update on the message digest. But when it is off, the message 2N/A * digest is not updated. The default is for the stream to be on. 2N/A * @see MessageDigest 2N/A * @see DigestInputStream 2N/A * @author Benjamin Renaud 2N/A private boolean on =
true;
2N/A * The message digest associated with this stream. 2N/A * Creates a digest output stream, using the specified output stream 2N/A * and message digest. 2N/A * @param stream the output stream. 2N/A * @param digest the message digest to associate with this stream. 2N/A * Returns the message digest associated with this stream. 2N/A * @return the message digest associated with this stream. 2N/A * @see #setMessageDigest(java.security.MessageDigest) 2N/A * Associates the specified message digest with this stream. 2N/A * @param digest the message digest to be associated with this stream. 2N/A * @see #getMessageDigest() 2N/A * Updates the message digest (if the digest function is on) using 2N/A * the specified byte, and in any case writes the byte 2N/A * to the output stream. That is, if the digest function is on 2N/A * (see {@link #on(boolean) on}), this method calls 2N/A * <code>update</code> on the message digest associated with this 2N/A * stream, passing it the byte <code>b</code>. This method then 2N/A * writes the byte to the output stream, blocking until the byte 2N/A * is actually written. 2N/A * @param b the byte to be used for updating and writing to the 2N/A * @exception IOException if an I/O error occurs. 2N/A * @see MessageDigest#update(byte) 2N/A * Updates the message digest (if the digest function is on) using 2N/A * the specified subarray, and in any case writes the subarray to 2N/A * the output stream. That is, if the digest function is on (see 2N/A * {@link #on(boolean) on}), this method calls <code>update</code> 2N/A * on the message digest associated with this stream, passing it 2N/A * the subarray specifications. This method then writes the subarray 2N/A * bytes to the output stream, blocking until the bytes are actually 2N/A * @param b the array containing the subarray to be used for updating 2N/A * and writing to the output stream. 2N/A * @param off the offset into <code>b</code> of the first byte to 2N/A * be updated and written. 2N/A * @param len the number of bytes of data to be updated and written 2N/A * from <code>b</code>, starting at offset <code>off</code>. 2N/A * @exception IOException if an I/O error occurs. 2N/A * @see MessageDigest#update(byte[], int, int) 2N/A * Turns the digest function on or off. The default is on. When 2N/A * it is on, a call to one of the <code>write</code> methods results in an 2N/A * update on the message digest. But when it is off, the message 2N/A * digest is not updated. 2N/A * @param on true to turn the digest function on, false to turn it 2N/A * Prints a string representation of this digest output stream and 2N/A * its associated message digest object.