1package org.bouncycastle.crypto.digests;
2
3import java.io.ByteArrayOutputStream;
4
5import org.bouncycastle.crypto.Digest;
6
7
8public class NullDigest
9    implements Digest
10{
11    private ByteArrayOutputStream bOut = new ByteArrayOutputStream();
12
13    public String getAlgorithmName()
14    {
15        return "NULL";
16    }
17
18    public int getDigestSize()
19    {
20        return bOut.size();
21    }
22
23    public void update(byte in)
24    {
25        bOut.write(in);
26    }
27
28    public void update(byte[] in, int inOff, int len)
29    {
30        bOut.write(in, inOff, len);
31    }
32
33    public int doFinal(byte[] out, int outOff)
34    {
35        byte[] res = bOut.toByteArray();
36
37        System.arraycopy(res, 0, out, outOff, res.length);
38
39        reset();
40
41        return res.length;
42    }
43
44    public void reset()
45    {
46        bOut.reset();
47    }
48}