public final class MD5 extends Object
An MD5 hash is typically expressed as a 32-digit hexadecimal number.
Modifier and Type | Method and Description |
---|---|
static String |
hash(File file)
Returns a hash value for the specified file content.
|
static String |
hash(File file,
boolean strong)
Returns a hash value for the specified file.
|
static String |
hash(String text)
Returns a hash value for the specified text.
|
public static String hash(String text) throws UnsupportedOperationException
text
- The text value to hash.null
if an error occurred.UnsupportedOperationException
- If the MD5 algorithm is not available for that platform.public static String hash(File file) throws IOException, UnsupportedOperationException
Implementation note: this method loads the entire file using NIO.
file
- The file to readIOException
- If the file does not exist or an error occurred while reading the file.UnsupportedOperationException
- If the MD5 algorithm is not available for that platform.public static String hash(File file, boolean strong) throws IOException, UnsupportedOperationException
file
- The file to readstrong
- true
to calculate a strong etag based on the file content;
false
to compute it from the canonical path, date and length.IOException
- If the file does not exist or an error occurred while reading the file.UnsupportedOperationException
- If the MD5 algorithm is not available for that platform.Copyright © 2016 Allette Systems. All rights reserved.