public class MD5InputStream
extends java.io.FilterInputStream
This class produces a 128-bit "fingerprint" or "message digest" for all data read from this stream. It is conjectured that it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given pre-specified target message digest. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA.
For more information see RFC1321.
MD5
,
MD5OutputStream
Constructor and Description |
---|
MD5InputStream(java.io.InputStream in)
Creates a MD5InputStream
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getHash()
Returns array of bytes representing hash of the stream so far.
|
java.lang.String |
getHashString()
Get a 32-character hex representation representing hash of the stream so far.
|
int |
read()
Reads the next byte of data from this input stream.
|
int |
read(byte[] bytes,
int offset,
int length)
Reads up to length bytes of data from this input stream into an
array of bytes.
|
public MD5InputStream(java.io.InputStream in)
in
- the underlying input streampublic int read() throws java.io.IOException
This method simply performs in.read() and returns the result.
read
in class java.io.FilterInputStream
java.io.IOException
- if an I/O error occurs.public int read(byte[] bytes, int offset, int length) throws java.io.IOException
read
in class java.io.FilterInputStream
bytes
- the buffer into which the data is read.offset
- the start offset of the data.length
- the maximum number of bytes read.java.io.IOException
- if an I/O error occurs.public byte[] getHash()
public java.lang.String getHashString()
Copyright (c) 2001-2020 by Stephen Ostermiller