net.rim.device.api.crypto
Class DigestOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.rim.device.api.crypto.CryptoOutputStream
          extended by net.rim.device.api.crypto.DigestOutputStream

public class DigestOutputStream
extends CryptoOutputStream

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.

See Also:
DigestInputStream
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

Field Summary
Category: Signed protected  Digest _digest
          Stores the digest used with this instance of the class for later use.
Category: Signed 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
Category: Signed DigestOutputStream(Digest digest, OutputStream out)
          Creates a DigestOutputStream object which takes as input a digest and an output stream.
 
Method Summary
Category: Signed  String getAlgorithm()
          Returns the name of this algorithm, eg "SHA1".
Category: Signed  Digest getDigest()
          Returns a reference to the digest being used with this digest input stream.
Category: Signed  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.
Category: Signed  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

_digest

protected Digest _digest
Stores the digest used with this instance of the class for later use.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

_on

protected boolean _on
A boolean that enables the user to turn the digest part of the input stream on or off at their will.

By default _on is set to true.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


Constructor Detail

DigestOutputStream

public DigestOutputStream(Digest digest,
                          OutputStream out)
Creates a DigestOutputStream object which takes as input a digest and an output stream.

Parameters:
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().
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


Method Detail

getAlgorithm

public String getAlgorithm()
Returns the name of this algorithm, eg "SHA1".

Specified by:
getAlgorithm in class CryptoOutputStream
Returns:
A String that represents the name of the algorithm.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

on

public 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.

Note that _on is true by default.

Parameters:
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.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

write

public void write(byte[] buffer,
                  int offset,
                  int length)
           throws IOException
Description copied from class: CryptoOutputStream
Writes a specified length of bytes from the given byte array to this output stream.

Specified by:
write in class CryptoOutputStream
Parameters:
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.

Throws:
IOException - Thrown if an I/O error occurs.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

getDigest

public Digest getDigest()
Returns a reference to the digest being used with this digest input stream.

Returns:
A reference to the digest.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0





Copyright 1999-2010 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. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.