sdsu.io
Class XorOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FilterOutputStream
              |
              +--sdsu.io.XorOutputStream

public class XorOutputStream
extends java.io.FilterOutputStream

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

Constructor Detail

XorOutputStream

public XorOutputStream(java.io.OutputStream out,
                       byte mask)
Method Detail

write

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

write

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