|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.security.DigestInputStream
org.nuiton.util.MD5InputStream
public class MD5InputStream
MD5InputStream, a subclass of FilterInputStream implementing MD5 functionality on a stream.
| Field Summary | |
|---|---|
protected long |
streamLength
length of readed stream |
| Fields inherited from class java.security.DigestInputStream |
|---|
digest |
| Fields inherited from class java.io.FilterInputStream |
|---|
in |
| Constructor Summary | |
|---|---|
MD5InputStream(InputStream in)
Creates a MD5InputStream |
|
| Method Summary | |
|---|---|
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)
|
| Methods inherited from class java.security.DigestInputStream |
|---|
getMessageDigest, on, setMessageDigest, toString |
| Methods inherited from class java.io.FilterInputStream |
|---|
available, close, mark, markSupported, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected long streamLength
| Constructor Detail |
|---|
public MD5InputStream(InputStream in)
in - The input stream| Method Detail |
|---|
protected 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 parse
IOException - if any pb while reading in stream or digest
public static byte[] hash(File input)
throws IOException
input file.
input - the File stream to parse
IOException - if any pb while reading in stream or digest
public static byte[] hash(String input)
throws IOException
input sring.
input - the stream to parse
IOException - if any pb while reading in stream or digest
public int read()
throws IOException
read in class DigestInputStreamIOException
public int read(byte[] bytes,
int offset,
int length)
throws IOException
read in class DigestInputStreamIOExceptionpublic byte[] hash()
MessageDigest.digest()public long getStreamLength()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||