sdsu.io
Class XorWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--java.io.FilterWriter
              |
              +--sdsu.io.XorWriter

public class XorWriter
extends java.io.FilterWriter

XorWriter encodes it output by Xoring all input chars with the char mask given in the constructor. Use a XorReader to decode the output of XorWriter by givening them both the same mask in their constructors. 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
XorWriter(java.io.Writer out, char mask)
           
 
Method Summary
 void write(char[] output, int offset, int length)
          Writes length chars from the specified char array starting at offset offset and Xor's each char with the stream's mask.
 void write(int output)
          Writes the specified char and Xor's it with the stream's mask.
 void write(java.lang.String output, int offset, int length)
          Writes length chars from the specified string starting at offset offset and Xor's each char with the stream's mask.
 
Methods inherited from class java.io.FilterWriter
close, flush
 
Methods inherited from class java.io.Writer
write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XorWriter

public XorWriter(java.io.Writer out,
                 char mask)
Method Detail

write

public void write(int output)
           throws java.io.IOException
Writes the specified char and Xor's it with the stream's mask.
Parameters:
output - the char.
Throws:
java.io.IOException - if an I/O error occurs.
Overrides:
write in class java.io.FilterWriter

write

public void write(char[] output,
                  int offset,
                  int length)
           throws java.io.IOException
Writes length chars from the specified char array starting at offset offset and Xor's each char with the stream's mask.
Parameters:
output - the data.
offset - the start offset in the data.
length - the number of chars to write.
Throws:
java.io.IOException - if an I/O error occurs.
Overrides:
write in class java.io.FilterWriter

write

public void write(java.lang.String output,
                  int offset,
                  int length)
           throws java.io.IOException
Writes length chars from the specified string starting at offset offset and Xor's each char with the stream's mask.
Parameters:
output - the data.
offset - the start offset in the data.
length - the number of chars to write.
Throws:
java.io.IOException - if an I/O error occurs.
Overrides:
write in class java.io.FilterWriter