1 package org.bouncycastle.crypto.io;
2
3 import java.io.*;
4
5 import org.bouncycastle.crypto.Digest;
6
7 public class DigestOutputStream
8 extends FilterOutputStream
9 {
10 protected Digest digest;
11
12 public DigestOutputStream(
13 OutputStream stream,
14 Digest digest)
15 {
16 super(stream);
17 this.digest = digest;
18 }
19
20 public void write(int b)
21 throws IOException
22 {
23 digest.update((byte)b);
24 out.write(b);
25 }
26
27 public void write(
28 byte[] b,
29 int off,
30 int len)
31 throws IOException
32 {
33 digest.update(b, off, len);
34 out.write(b, off, len);
35 }
36
37 public Digest getDigest()
38 {
39 return digest;
40 }
41 }
42