@Deprecated public class MessageDigestCalculatingInputStream extends ObservableInputStream
ObservableInputStream
. It creates its own ObservableInputStream.Observer
,
which calculates a checksum using a MessageDigest
, for example, a SHA-512 sum.
To build an instance, see MessageDigestCalculatingInputStream.Builder
.
See the MessageDigest section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names.
Note: Neither ObservableInputStream
, nor MessageDigest
, are thread safe, so is MessageDigestCalculatingInputStream
.
Modifier and Type | Class and Description |
---|---|
static class |
MessageDigestCalculatingInputStream.Builder
Deprecated.
Builds a new
MessageDigestCalculatingInputStream instance. |
static class |
MessageDigestCalculatingInputStream.MessageDigestMaintainingObserver
Deprecated.
Maintains the message digest.
|
ObservableInputStream.Observer
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
DEFAULT_ALGORITHM
Deprecated.
The default message digest algorithm.
|
private java.security.MessageDigest |
messageDigest
Deprecated.
|
Constructor and Description |
---|
MessageDigestCalculatingInputStream(java.io.InputStream inputStream)
|
MessageDigestCalculatingInputStream(java.io.InputStream inputStream,
java.security.MessageDigest messageDigest)
|
MessageDigestCalculatingInputStream(java.io.InputStream inputStream,
java.lang.String algorithm)
|
Modifier and Type | Method and Description |
---|---|
static MessageDigestCalculatingInputStream.Builder |
builder()
Deprecated.
Constructs a new
MessageDigestCalculatingInputStream.Builder . |
(package private) static java.security.MessageDigest |
getDefaultMessageDigest()
Deprecated.
Gets a MessageDigest object that implements the default digest algorithm.
|
java.security.MessageDigest |
getMessageDigest()
Deprecated.
Gets the
MessageDigest , which is being used for generating the checksum. |
add, close, consume, getObservers, noteClosed, noteDataByte, noteDataBytes, noteError, noteFinished, read, read, read, remove, removeAllObservers
afterRead, available, beforeRead, handleIOException, mark, markSupported, reset, skip
private static final java.lang.String DEFAULT_ALGORITHM
The MD5 cryptographic algorithm is weak and should not be used.
private final java.security.MessageDigest messageDigest
@Deprecated public MessageDigestCalculatingInputStream(java.io.InputStream inputStream) throws java.security.NoSuchAlgorithmException
builder()
, MessageDigestCalculatingInputStream.Builder
, and MessageDigestCalculatingInputStream.Builder.get()
.MessageDigest
with the "MD5" algorithm.
The MD5 algorithm is weak and should not be used.
inputStream
- the stream to calculate the message digest forjava.security.NoSuchAlgorithmException
- if no Provider supports a MessageDigestSpi implementation for the specified algorithm.@Deprecated public MessageDigestCalculatingInputStream(java.io.InputStream inputStream, java.security.MessageDigest messageDigest)
builder()
, MessageDigestCalculatingInputStream.Builder
, and MessageDigestCalculatingInputStream.Builder.get()
.MessageDigest
.
The MD5 cryptographic algorithm is weak and should not be used.
inputStream
- the stream to calculate the message digest formessageDigest
- the message digest to usejava.lang.NullPointerException
- if messageDigest is null.@Deprecated public MessageDigestCalculatingInputStream(java.io.InputStream inputStream, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
builder()
, MessageDigestCalculatingInputStream.Builder
, and MessageDigestCalculatingInputStream.Builder.get()
.MessageDigest
with the given algorithm.
The MD5 cryptographic algorithm is weak and should not be used.
inputStream
- the stream to calculate the message digest foralgorithm
- the name of the algorithm requested. See the MessageDigest section in the
Java Cryptography
Architecture Standard Algorithm Name Documentation for information about standard algorithm names.java.security.NoSuchAlgorithmException
- if no Provider supports a MessageDigestSpi implementation for the specified algorithm.public static MessageDigestCalculatingInputStream.Builder builder()
MessageDigestCalculatingInputStream.Builder
.MessageDigestCalculatingInputStream.Builder
.static java.security.MessageDigest getDefaultMessageDigest() throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
- if no Provider supports a MessageDigestSpi implementation.Provider
public java.security.MessageDigest getMessageDigest()
MessageDigest
, which is being used for generating the checksum.
Note: The checksum will only reflect the data, which has been read so far. This is probably not, what you expect. Make sure, that the complete
data has been read, if that is what you want. The easiest way to do so is by invoking ObservableInputStream.consume()
.