Package com.ibm.fhir.bucket.scanner
Class Sha256InputStreamDecorator
- java.lang.Object
-
- java.io.InputStream
-
- com.ibm.fhir.bucket.scanner.Sha256InputStreamDecorator
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class Sha256InputStreamDecorator extends java.io.InputStream
Decorates an InputStream with the ability to compute a SHA-256 hash of the bytes read from the stream. Assumes that the entire stream is read. If buffering is done further up-stream, then obviously the digest may not represent what was actually read by the consumer, because the buffer may read bytes from this stream than were actually consumed. Caveat emptor.
-
-
Constructor Summary
Constructors Constructor Description Sha256InputStreamDecorator(java.io.InputStream delegate)
Public Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
java.lang.String
getBase64Hash()
Compute the digest.int
read()
int
read(byte[] b, int off, int len)
-
-
-
Method Detail
-
getBase64Hash
public java.lang.String getBase64Hash()
Compute the digest. Resets the state- Returns:
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
-