Package org.savantbuild.security
Class MD5
java.lang.Object
org.savantbuild.security.MD5
This class is a simple holder for a MD5 checksum. It holds the sum and the file name. It can also hold the MD5 sum
bytes.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
bytes
public final byte[] bytes -
fileName
-
sum
-
-
Constructor Details
-
MD5
-
-
Method Details
-
forBytes
Calculates the MD5 for the given bytes. This optionally takes a file name, which isn't required, but can be useful when calculating MD5s for files.- Parameters:
bytes- The bytes.fileName- (Optional) The file name.- Returns:
- The MD5 and never null.
- Throws:
IOException- If the MD5 fails for any reason.
-
forPath
Calculates the MD5 sum for the given Path.- Parameters:
path- The path to MD5.- Returns:
- The MD5 sum and never null.
- Throws:
IOException- If the file could not be MD5 summed.
-
load
Loads the MD5 file at the given Path. This doesn't calculate the MD5 for the given path. The given path must be an MD5 file.- Parameters:
path- The path to parse the MD5 sum from.- Returns:
- The MD5.
- Throws:
IOException- If the MD5 file is not a valid MD5 file or was unreadable.
-
writeMD5
Writes the MD5 information out to the given Path file.- Parameters:
md5- The MD5.path- The path to write the MD5 to.- Throws:
IOException- If the write fails.
-
equals
-
hashCode
public int hashCode()
-