org.nuiton.util
Class MD5InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.nuiton.util.MD5InputStream
All Implemented Interfaces:
Closeable

public class MD5InputStream
extends FilterInputStream

MD5InputStream, a subclass of FilterInputStream implementing MD5 functionality on a stream.

Originally written by Santeri Paavolainen, Helsinki Finland 1996
(c) Santeri Paavolainen, Helsinki Finland 1996
Some changes Copyright (c) 2002 Timothy W Macinta

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

See http://www.twmacinta.com/myjava/fast_md5.php for more information on this file.

Please note: I (Timothy Macinta) have put this code in the com.twmacinta.util package only because it came without a package. I was not the the original author of the code, although I did optimize it (substantially) and fix some bugs.

Author:
Santeri Paavolainen , Timothy W Macinta (twm@alum.mit.edu) (added main() method)

Field Summary
protected  MD5 md5
          MD5 context
protected  long streamLength
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
MD5InputStream(InputStream in)
          Creates a MD5InputStream
 
Method Summary
 MD5 getMD5()
           
 long getStreamLength()
           
 byte[] hash()
          Returns array of bytes representing hash of the stream as finalized for the current state.
 int read()
           
 int read(byte[] bytes, int offset, int length)
           
 
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, toString, wait, wait, wait
 

Field Detail

md5

protected MD5 md5
MD5 context


streamLength

protected long streamLength
Constructor Detail

MD5InputStream

public MD5InputStream(InputStream in)
Creates a MD5InputStream

Parameters:
in - The input stream
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] bytes,
                int offset,
                int length)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

hash

public byte[] hash()
Returns array of bytes representing hash of the stream as finalized for the current state.

Returns:
hash
See Also:
MD5.Final()

getMD5

public MD5 getMD5()

getStreamLength

public long getStreamLength()


Copyright © 2004-2010 CodeLutin. All Rights Reserved.