edu.emory.mathcs.util.security
Class DigestUtils

java.lang.Object
  extended byedu.emory.mathcs.util.security.DigestUtils

public class DigestUtils
extends java.lang.Object

Utility methods to manipulate message digests.

Version:
1.0
Author:
Dawid Kurzyniec
See Also:
MessageDigest

Method Summary
static byte[] calculateDigest(java.io.InputStream in, java.security.MessageDigest digest)
           
static byte[] calculateMD5Digest(java.io.InputStream in)
           
static byte[] calculateSHADigest(java.io.InputStream in)
           
static java.security.MessageDigest getMD5Digest()
          Returns an instance of MD5 digest.
static java.security.DigestInputStream getMD5DigestInputStream(java.io.InputStream is)
          Wraps specified input stream into an digest stream that calculates the MD5 digest as it reads.
static java.security.DigestOutputStream getMD5DigestOutputStream(java.io.OutputStream os)
          Wraps specified output stream into an digest stream that calculates the MD5 digest as it writes.
static java.security.MessageDigest getSHADigest()
          Returns an instance of SHA digest.
static java.security.DigestInputStream getSHADigestInputStream(java.io.InputStream is)
          Wraps specified input stream into an digest stream that calculates the SHA digest as it reads.
static java.security.DigestOutputStream getSHADigestOutputStream(java.io.OutputStream os)
          Wraps specified output stream into an digest stream that calculates the SHA digest as it writes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSHADigest

public static java.security.MessageDigest getSHADigest()
Returns an instance of SHA digest.

Returns:
an instance of SHA digest

getMD5Digest

public static java.security.MessageDigest getMD5Digest()
Returns an instance of MD5 digest.

Returns:
an instance of MD5 digest

getSHADigestInputStream

public static java.security.DigestInputStream getSHADigestInputStream(java.io.InputStream is)
Wraps specified input stream into an digest stream that calculates the SHA digest as it reads.

Parameters:
is - the input stream to wrap
Returns:
wrapping digest input stream

getMD5DigestInputStream

public static java.security.DigestInputStream getMD5DigestInputStream(java.io.InputStream is)
Wraps specified input stream into an digest stream that calculates the MD5 digest as it reads.

Parameters:
is - the input stream to wrap
Returns:
wrapping digest input stream

getSHADigestOutputStream

public static java.security.DigestOutputStream getSHADigestOutputStream(java.io.OutputStream os)
Wraps specified output stream into an digest stream that calculates the SHA digest as it writes.

Parameters:
os - the output stream to wrap
Returns:
wrapping digest output stream

getMD5DigestOutputStream

public static java.security.DigestOutputStream getMD5DigestOutputStream(java.io.OutputStream os)
Wraps specified output stream into an digest stream that calculates the MD5 digest as it writes.

Parameters:
os - the output stream to wrap
Returns:
wrapping digest output stream

calculateDigest

public static byte[] calculateDigest(java.io.InputStream in,
                                     java.security.MessageDigest digest)
                              throws java.io.IOException
Throws:
java.io.IOException

calculateSHADigest

public static byte[] calculateSHADigest(java.io.InputStream in)
                                 throws java.io.IOException
Throws:
java.io.IOException

calculateMD5Digest

public static byte[] calculateMD5Digest(java.io.InputStream in)
                                 throws java.io.IOException
Throws:
java.io.IOException