|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
net.rim.device.api.crypto.CryptoOutputStream
net.rim.device.api.crypto.DigestOutputStream
public class DigestOutputStream
Allows for a user to open an output stream and run a digest on all information that passes through that output stream.
This is useful when a hash is required on a data stream for another program or even another class.
DigestInputStream
Field Summary | ||
---|---|---|
|
protected Digest |
_digest
Stores 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.CryptoOutputStream |
---|
_out |
Constructor Summary | ||
---|---|---|
|
DigestOutputStream(Digest digest,
OutputStream out)
Creates a DigestOutputStream object which takes as input a digest and an output 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 decide whether or not they want the data being written to go through the digest function as well. |
|
void |
write(byte[] buffer,
int offset,
int length)
Writes a specified length of bytes from the given byte array to this output stream. |
Methods inherited from class net.rim.device.api.crypto.CryptoOutputStream |
---|
close, flush, getOutputStream, write, write |
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 DigestOutputStream(Digest digest, OutputStream out)
DigestOutputStream
object which takes as input a digest and an output stream.
digest
- The digest that will be used for hashing all of the data
output to the stream.out
- The underlying output stream where data is written.
If this is null, no output stream is used, and only the digest
is evaluated during calls to write()
.Method Detail |
---|
public String getAlgorithm()
getAlgorithm
in class CryptoOutputStream
public void on(boolean on)
Note that _on is true by default.
on
- When true, tells the program to pass the
data written to the stream through the digest as well. If false, then
this data is not passed through the digest but is simply
written to the stream.public void write(byte[] buffer, int offset, int length) throws IOException
CryptoOutputStream
write
in class CryptoOutputStream
buffer
- The byte array containing the bytes that are
going to be written to the output stream.offset
- The offset in the byte array where the method
will start writing from.length
- The number of bytes that will be written to
the output stream.
IOException
- Thrown if an I/O error occurs.public Digest getDigest()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal