All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.io.XorInputStream

java.lang.Object
   |
   +----java.io.InputStream
           |
           +----java.io.FilterInputStream
                   |
                   +----sdsu.io.XorInputStream

public class XorInputStream
extends FilterInputStream
XorInputStream is an inputstream that Xor all input bytes with the byte mask given in the constructor. Use to decode output of a XorOutputStream by giving it the XorInputStream the same byte mask as XorOutputStream. XorInputStream and XorOutputStream can be used for a very weak form of encryption.

Version:
1.0 14 Feb 1998
Author:
Roger Whitney (whitney@cs.sdsu.edu)

Constructor Index

 o XorInputStream(InputStream, byte)
Create an XorInputStream on the given input stream.

Method Index

 o read()
Reads the next byte of data and Xors it with the mask given in the constructor.
 o read(byte[], int, int)
Reads up to length bytes of data and Xor each byte.

Constructors

 o XorInputStream
 public XorInputStream(InputStream in,
                       byte mask)
Create an XorInputStream on the given input stream.

Parameters:
mask - the bit pattern with which all input bytes will be Xored

Methods

 o read
 public int read() throws IOException
Reads the next byte of data and Xors it with the mask given in the constructor. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws: IOException
if an I/O error occurs.
Overrides:
read in class FilterInputStream
 o read
 public int read(byte inputBuffer[],
                 int offset,
                 int length) throws IOException
Reads up to length bytes of data and Xor each byte. This method blocks until some input is available.

Parameters:
inputBuffer - the buffer into which the data is read.
offset - the start offset of the data.
length - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws: IOException
if an I/O error occurs.
Overrides:
read in class FilterInputStream

All Packages  Class Hierarchy  This Package  Previous  Next  Index