1 package net.sourceforge.jcetaglib.tools; 2 3 import javax.crypto.Mac; 4 import java.io.FilterOutputStream ; 5 import java.io.IOException ; 6 import java.io.OutputStream ; 7 8 11 12 public class MacOutputStream extends FilterOutputStream { 13 private Mac mac = null; 14 15 public MacOutputStream(OutputStream out, 16 Mac mac) { 17 super(out); 18 this.mac = mac; 19 } 20 21 public void write(int b) 22 throws IOException { 23 mac.update((byte) b); 24 out.write(b); 25 } 26 27 public void write(byte[] b) 28 throws IOException { 29 mac.update(b); 30 out.write(b); 31 } 32 33 public void write(byte[] b, 34 int o, 35 int l) 36 throws IOException { 37 mac.update(b, o, l); 38 out.write(b, o, l); 39 } 40 } 41 | Popular Tags |