1 50 51 package com.lowagie.text.pdf; 52 53 import java.io.FilterOutputStream; 54 import java.io.OutputStream; 55 import java.io.IOException; 56 57 public class PdfEncryptionStream extends FilterOutputStream { 58 59 protected PdfEncryption enc; 60 private byte buf[] = new byte[1]; 61 62 public PdfEncryptionStream(OutputStream out, PdfEncryption enc) { 63 super(out); 64 this.enc = enc; 65 } 66 67 public void write(byte[] b, int off, int len) throws IOException { 68 if ((off | len | (b.length - (len + off)) | (off + len)) < 0) 69 throw new IndexOutOfBoundsException(); 70 enc.encryptRC4(b, off, len); 71 out.write(b, off, len); 72 } 73 74 public void close() throws IOException { 75 } 76 77 public void write(int b) throws IOException { 78 buf[0] = (byte)b; 79 write(buf); 80 } 81 82 public void flush() throws IOException { 83 } 84 85 } 86 | Popular Tags |