@@ -0,0 +1,1913 @@
+package org.cryptonit.cloud.timestamping;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.OutputStream;%0Aimport org.bouncycastle.asn1.ASN1ObjectIdentifier;%0Aimport org.bouncycastle.asn1.nist.NISTObjectIdentifiers;%0Aimport org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;%0Aimport org.bouncycastle.asn1.x509.AlgorithmIdentifier;%0Aimport org.bouncycastle.crypto.Digest;%0Aimport org.bouncycastle.crypto.digests.SHA1Digest;%0Aimport org.bouncycastle.crypto.digests.SHA256Digest;%0Aimport org.bouncycastle.crypto.digests.SHA384Digest;%0Aimport org.bouncycastle.crypto.digests.SHA512Digest;%0Aimport org.bouncycastle.operator.DigestCalculator;%0A%0A/**%0A * @author Mathias Brossard%0A */%0Apublic class GenericDigestCalculator implements DigestCalculator %7B%0A%0A    private ASN1ObjectIdentifier algo;%0A    private ByteArrayOutputStream bOut = new ByteArrayOutputStream();%0A%0A    public GenericDigestCalculator(ASN1ObjectIdentifier algo) %7B%0A        this.algo = algo;%0A    %7D%0A%0A    @Override%0A    public AlgorithmIdentifier getAlgorithmIdentifier() %7B%0A        return new AlgorithmIdentifier(this.algo);%0A    %7D%0A%0A    @Override%0A    public OutputStream getOutputStream() %7B%0A        return bOut;%0A    %7D%0A%0A    @Override%0A    public byte%5B%5D getDigest() %7B%0A        byte%5B%5D bytes = bOut.toByteArray();%0A        bOut.reset();%0A%0A        Digest d;%0A        if (this.algo.equals(OIWObjectIdentifiers.idSHA1)) %7B%0A            d = new SHA1Digest();%0A        %7D else if (this.algo.equals(NISTObjectIdentifiers.id_sha256)) %7B%0A            d = new SHA256Digest();%0A        %7D else if (this.algo.equals(NISTObjectIdentifiers.id_sha384)) %7B%0A            d = new SHA384Digest();%0A        %7D else if (this.algo.equals(NISTObjectIdentifiers.id_sha512)) %7B%0A            d = new SHA512Digest();%0A        %7D else %7B%0A            return null;%0A        %7D%0A        d.update(bytes, 0, bytes.length);%0A        byte%5B%5D digest = new byte%5Bd.getDigestSize()%5D;%0A        d.doFinal(digest, 0);%0A        return digest;%0A    %7D%0A%7D%0A

Add GenericDigestCalculator class