Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.security

Class DigestInputStream

java.lang.Object
|
+--java.io.InputStream
   |
   +--java.io.FilterInputStream
      |
      +--java.security.DigestInputStream


public class DigestInputStream

extends FilterInputStream

DigestInputStream is a class that ties an InputStream with a MessageDigest. The Message Digest is used by the class to update it self as bytes are read from the InputStream. The updating to the digest depends on the on flag which is set to true by default to tell the class to update the data in the message digest.

Author:

Field Summary

java.security.MessageDigestdigest

The message digest for the DigestInputStream

Constructor Summary

DigestInputStream(java.io.InputStream stream, java.security.MessageDigest digest)

Constructs a new DigestInputStream.

Method Summary

java.security.MessageDigestgetMessageDigest()

Returns the MessageDigest associated with this DigestInputStream
voidon(boolean on)

Sets the flag specifing if this DigestInputStream updates the digest in the write() methods.
intread()

Reads a byte from the input stream and updates the digest.
intread(byte[] , int off, int len)

Reads bytes from the input stream and updates the digest.
voidsetMessageDigest(java.security.MessageDigest digest)

Sets the current MessageDigest to current parameter
java.lang.StringtoString()

Converts the input stream and underlying message digest to a string.

Field Details

digest

protected MessageDigest digest

The message digest for the DigestInputStream


Constructor Details

DigestInputStream

public DigestInputStream(java.io.InputStream stream, java.security.MessageDigest digest)

Constructs a new DigestInputStream. It associates a MessageDigest with the stream to compute the stream as data is written.

Parameters:


Method Details

getMessageDigest

public MessageDigest getMessageDigest()

Returns the MessageDigest associated with this DigestInputStream

Returns:


on

public void on(boolean on)

Sets the flag specifing if this DigestInputStream updates the digest in the write() methods. The default is on;

Parameters:


read

public int read()

Reads a byte from the input stream and updates the digest. This method reads the underlying input stream and if the on flag is true then updates the message digest.

Returns:

Throws:


read

public int read(byte[] , int off, int len)

Reads bytes from the input stream and updates the digest. This method reads the underlying input stream and if the on flag is true then updates the message digest.

Parameters:

Returns:

Throws:


setMessageDigest

public void setMessageDigest(java.security.MessageDigest digest)

Sets the current MessageDigest to current parameter

Parameters:


toString

public String toString()

Converts the input stream and underlying message digest to a string.

Returns: