Skip to content

Instantly share code, notes, and snippets.

@md-5
Created May 23, 2012 06:30
Show Gist options
  • Save md-5/2773546 to your computer and use it in GitHub Desktop.
Save md-5/2773546 to your computer and use it in GitHub Desktop.
package com.raphfrk.craftproxylitest;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.bouncycastle.crypto.StreamCipher;
public class CiphOut extends FilterOutputStream {
private StreamCipher ciph;
public CiphOut(OutputStream out, StreamCipher ciph) {
super(out);
this.ciph = ciph;
}
@Override
public void write(int b) throws IOException {
out.write(ciph.returnByte((byte) b));
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
byte[] bytes;
bytes = new byte[len];
ciph.processBytes(b, off, len, bytes, 0);
out.write(bytes, 0, len);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment