Many bugfixes and improvements

This commit is contained in:
Ziver Koc 2011-06-24 23:20:59 +00:00
parent c3e3bbf787
commit 363e0c6cfc
52 changed files with 2021 additions and 982 deletions

View file

@ -21,7 +21,7 @@ public class Hasher {
* @return a String with the hash
*/
public static String hash(File file, String hashType) throws NoSuchAlgorithmException, IOException {
MessageDigest digest = MessageDigest.getInstance(hashType);//"MD5"
MessageDigest digest = MessageDigest.getInstance(hashType); //"MD5"
InputStream is = new FileInputStream(file);
String output = "";
byte[] buffer = new byte[8192];
@ -71,6 +71,22 @@ public class Hasher {
}
return null;
}
/**
* Returns the MD5 hash of the given file
*
* @param object is the file to hash
* @return an String containing the hash
*/
public static String MD5(File file) throws IOException{
try {
return hash(file, "MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}
/**
* Returns the SHA-1 hash of the given object