01: package org.bouncycastle.crypto.io;
02:
03: import java.io.FilterOutputStream;
04: import java.io.IOException;
05: import java.io.OutputStream;
06:
07: import org.bouncycastle.crypto.Digest;
08:
09: public class DigestOutputStream extends FilterOutputStream {
10: protected Digest digest;
11:
12: public DigestOutputStream(OutputStream stream, Digest digest) {
13: super (stream);
14: this .digest = digest;
15: }
16:
17: public void write(int b) throws IOException {
18: digest.update((byte) b);
19: out.write(b);
20: }
21:
22: public void write(byte[] b, int off, int len) throws IOException {
23: digest.update(b, off, len);
24: out.write(b, off, len);
25: }
26:
27: public Digest getDigest() {
28: return digest;
29: }
30: }
|