public class MD5Helper
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BUFFER_SIZE
Use a 100000 byte buffer when creating a buffer for reading.
|
| Constructor and Description |
|---|
MD5Helper() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getHash(java.io.File file)
Get the MD5 hash code for the given file.
|
static byte[] |
getHash(java.io.InputStream is)
Get the MD5 hash code for the given input stream.
|
static byte[] |
getHash(java.lang.String value)
Get the MD5 hash code for the given string.
|
static void |
hashOfFilesOfDirectory(java.io.File dir) |
static void |
main(java.lang.String[] arr) |
static java.lang.String |
toString(byte[] hash)
Get a formatted string from hash array.
|
static java.lang.String |
toString(byte[] hash,
java.lang.String format)
Get a formatted string from hash array.
|
public static final int BUFFER_SIZE
public static byte[] getHash(java.io.File file)
throws java.security.NoSuchAlgorithmException,
java.io.IOException
file - the file to be hashed.java.security.NoSuchAlgorithmExceptionjava.io.IOExceptionpublic static byte[] getHash(java.io.InputStream is)
throws java.security.NoSuchAlgorithmException,
java.io.IOException
is - the input stream to be hashed.java.security.NoSuchAlgorithmExceptionjava.io.IOExceptionpublic static byte[] getHash(java.lang.String value)
throws java.security.NoSuchAlgorithmException
value - the valuejava.security.NoSuchAlgorithmExceptionpublic static java.lang.String toString(byte[] hash)
hash - the has arrayMessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)public static java.lang.String toString(byte[] hash,
java.lang.String format)
hash - the has arrayformat - the format string used by the java.text.MessageFormat classMessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)public static void hashOfFilesOfDirectory(java.io.File dir)
throws java.lang.Exception
java.lang.Exceptionpublic static void main(java.lang.String[] arr)