XorInputStreampublic class XorInputStream extends FilterInputStream
Fields Summary |
---|
private byte | pattern |
Constructors Summary |
---|
public XorInputStream(InputStream in, byte pattern)
/*
* Constructor for class XorInputStream
*/
super(in);
if (pattern != 0)
this.pattern = pattern;
|
Methods Summary |
---|
public int | read()
int b = in.read();
//If not end of file or an error, truncate b to one byte
if (b != -1)
b = (b ^ pattern) & 0xFF;
return b;
| public int | read(byte[] b, int off, int len)
int numBytes = in.read(b, off, len);
if (numBytes <= 0)
return numBytes;
int i = 0;
for(; i < numBytes; i++) {
b[off + i] = (byte)((b[off + i] ^ pattern) & 0xFF);
}
return i;
|
|