sdsu.io
Class XorReader
java.lang.Object
|
+--java.io.Reader
|
+--java.io.FilterReader
|
+--sdsu.io.XorReader
- public class XorReader
- extends java.io.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 Summary |
XorReader(java.io.Reader in,
char mask)
Create an XorReader on the given input stream. |
Method Summary |
int |
read()
Reads the next char of data and Xors it with the mask
given in the constructor. |
int |
read(char[] inputBuffer,
int offset,
int length)
Reads up to length chars of data and Xor each char. |
Methods inherited from class java.io.FilterReader |
close,
mark,
markSupported,
ready,
reset,
skip |
Methods inherited from class java.io.Reader |
read |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
XorReader
public XorReader(java.io.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
read
public int read()
throws java.io.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:
- java.io.IOException - if an I/O error occurs.
- Overrides:
- read in class java.io.FilterReader
read
public int read(char[] inputBuffer,
int offset,
int length)
throws java.io.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:
- java.io.IOException - if an I/O error occurs.
- Overrides:
- read in class java.io.FilterReader