All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sdsu.io.XorReader

java.lang.Object
   |
   +----java.io.Reader
           |
           +----java.io.FilterReader
                   |
                   +----sdsu.io.XorReader

public class XorReader
extends FilterReader
XorReader is an inputstream that Xor all input bytes with the byte mask given in the constructor. Use to decode output of a XorWriter by giving it the XorReader the same byte mask as XorWriter. XorReader and XorWriter 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 XorReader(Reader, char)
Create an XorReader on the given input stream.

Method Index

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

Constructors

 o XorReader
 public XorReader(Reader in,
                  char mask)
Create an XorReader 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 char of data and Xors it with the mask given in the constructor. If no char 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 char of data, or -1 if the end of the stream is reached.
Throws: IOException
if an I/O error occurs.
Overrides:
read in class FilterReader
 o read
 public int read(char inputBuffer[],
                 int offset,
                 int length) throws IOException
Reads up to length chars of data and Xor each char. 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 chars read.
Returns:
the total number of chars 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 FilterReader

All Packages  Class Hierarchy  This Package  Previous  Next  Index