[TOC] [Prev] [Next]

Secure Hash Stream


The SHAOutputStream provides an implementation of the National Institute of Standards and Technology (NIST) Secure Hash Algorithm (SHA). Its output is a 160-bit (20 byte) secure hash of the bytes written.


package java.io;
public class SHAOutputStream
	extends OutputStream
{
	public SHAOutputStream();
	public void write(int);
	public native void write(byte [],int,int);
	public native void reset();
	public native byte[] getHash();
}


Make a new secure hash stream with new SHAOutputStream.

The write method appends a byte to the buffer to be hashed.

The second write method accepts arrays or parts of arrays.

The reset method reinitializes the hash to its initial value. Values from all previous write method calls are discarded.

The getHash method returns the 20 byte array containing the hash value. Offset 0 in the array contains the most significant byte of the hash. SHA defines the result as 5 32 bit values but bytes are more convenient for writing and reading.



[TOC] [Prev] [Next]

rmi-comments@jse.East.Sun.COM
Copyright © 1996, Sun Microsystems, Inc. All rights reserved.