public class MD5InputStream extends DigestInputStream
Modifier and Type | Field and Description |
---|---|
protected long |
streamLength
length of readed stream
|
digest
in
Constructor and Description |
---|
MD5InputStream(InputStream in)
Creates a MD5InputStream
|
Modifier and Type | Method and Description |
---|---|
protected static MessageDigest |
getMD5Digest() |
long |
getStreamLength() |
byte[] |
hash()
Returns array of bytes representing hash of the stream as finalized for
the current state.
|
static byte[] |
hash(File input)
Compute the MD5 for the given
input file. |
static byte[] |
hash(InputStream input)
Compute the MD5 for the given
input . |
static byte[] |
hash(String input)
Compute the MD5 for the given
input sring. |
int |
read() |
int |
read(byte[] bytes,
int offset,
int length) |
getMessageDigest, on, setMessageDigest, toString
available, close, mark, markSupported, read, reset, skip
public MD5InputStream(InputStream in)
in
- The input streamprotected static MessageDigest getMD5Digest() throws IllegalStateException
IllegalStateException
public static byte[] hash(InputStream input) throws IOException
input
.
Note: The the stream will be closed after calling the method
even if something was wrong.input
- the stream to parseIOException
- if any pb while reading in stream or digestpublic static byte[] hash(File input) throws IOException
input
file.input
- the File stream to parseIOException
- if any pb while reading in stream or digestpublic static byte[] hash(String input) throws IOException
input
sring.input
- the stream to parseIOException
- if any pb while reading in stream or digestpublic int read() throws IOException
read
in class DigestInputStream
IOException
public int read(byte[] bytes, int offset, int length) throws IOException
read
in class DigestInputStream
IOException
public byte[] hash()
MessageDigest.digest()
public long getStreamLength()
Copyright © 2004–2020 CodeLutin. All rights reserved.