1 24 package com.Ostermiller.util; 25 26 import java.io.*; 27 28 52 public class MD5OutputStream extends FilterOutputStream { 53 54 57 private MD5 md5; 58 59 65 public MD5OutputStream(OutputStream out) { 66 super(out); 67 md5 = new MD5(); 68 } 69 70 78 public void write(int b) throws IOException { 79 out.write(b); 80 md5.update((byte)(b & 0xff)); 81 } 82 83 94 public void write(byte b[], int off, int len) throws IOException { 95 out.write(b, off, len); 96 md5.update(b, off, len); 97 } 98 99 106 public byte[] getHash(){ 107 return md5.getHash(); 108 } 109 110 117 public String getHashString(){ 118 return md5.getHashString(); 119 } 120 } 121 122 | Popular Tags |