|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.io.InputStream
|
+--net.rim.device.api.crypto.CryptoInputStream
|
+--net.rim.device.api.crypto.DigestInputStream
Allows for a user to open an input stream and run a digest on all information that passes through that input stream.
This is incredibly useful when a hash is required on a data stream from another program or even another class.
DigestOutputStream| Field Summary | ||
|
protected Digest |
_digest
A protected variable used to store the digest used with this instance of the class for later use. |
|
protected boolean |
_on
A boolean that enables the user to turn the digest part of the input stream on or off at their will. |
| Fields inherited from class net.rim.device.api.crypto.CryptoInputStream |
_inputStream |
| Constructor Summary | ||
|
DigestInputStream(Digest digest,
InputStream inputStream)
Creates a DigestInputStream object from a digest and an underlying input stream. |
|
| Method Summary | ||
|
String |
getAlgorithm()
Returns the name of this algorithm, eg "SHA1". |
|
Digest |
getDigest()
Returns a reference to the digest being used with this digest input stream. |
|
void |
on(boolean on)
Enables the user to turn on whether or not they want the data being read to go through the digest function as well. |
|
int |
read(byte[] buffer,
int offset,
int length)
Reads up to the specified number of bytes from this input stream into an array of bytes. |
| Methods inherited from class net.rim.device.api.crypto.CryptoInputStream |
available, close, getInputStream, markSupported, read, read |
| Methods inherited from class java.io.InputStream |
mark, reset, skip |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Digest _digest
protected boolean _on
By default, _on is set to true.
| Constructor Detail |
public DigestInputStream(Digest digest, InputStream inputStream)
DigestInputStream object from a digest and an underlying input stream.
digest - The digest that will be used for hashing all of the
data read from the stream.inputStream - The input stream that will be used to read the data from.| Method Detail |
public String getAlgorithm()
getAlgorithm in class CryptoInputStream
CryptoInputStreampublic Digest getDigest()
public void on(boolean on)
Note that _on is true by default.
on - When true, tells the program to pass the
data read through the digest as well. If false, then
this data is not passed through the digest but simply
returned to the user.
public int read(byte[] buffer,
int offset,
int length)
throws IOException
CryptoInputStreamread in class CryptoInputStream
CryptoInputStreambuffer - The buffer into which the data is read.offset - The starting offset within the buffer, to store the data.length - The maximum number of bytes to read.IOException - Thrown if an I/O error occurs.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2008 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.