Temporarily include bndlib 1.47 for testing purposes (not yet on central)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1185095 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java b/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
new file mode 100644
index 0000000..50b9659
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/libg/cryptography/Digester.java
@@ -0,0 +1,35 @@
+package aQute.libg.cryptography;
+
+import java.io.*;
+import java.security.*;
+
+import aQute.lib.io.*;
+
+public abstract class Digester<T extends Digest> extends OutputStream {
+ protected MessageDigest md;
+
+ public Digester(MessageDigest instance){
+ md = instance;
+ }
+ @Override
+ public void write( byte[] buffer, int offset, int length) throws IOException{
+ md.update(buffer,offset,length);
+ }
+ @Override
+ public void write( int b) throws IOException{
+ md.update((byte) b);
+ }
+
+ public MessageDigest getMessageDigest() throws Exception {
+ return md;
+ }
+
+ public T from(InputStream in) throws Exception {
+ IO.copy(in,this);
+ return digest();
+ }
+
+ public abstract T digest() throws Exception;
+ public abstract T digest( byte [] bytes) throws Exception;
+ public abstract String getAlgorithm();
+}