git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@50874 248e525c-4dfb-0310-94bc-949c084e9493

This commit is contained in:
andrew.gilmore
2012-03-19 11:57:19 +00:00
parent 2a0f4900c3
commit 0e9ca75d77
1587 changed files with 500863 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
/*
* HashFile.java
*
* Created on 2007. janu<6E>r 21., 17:55
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package tsdemo;
import java.security.MessageDigest;
import java.io.FileInputStream;
/**
*
* @author root
*/
public class HashFile {
/** Creates a new instance of HashFile */
public HashFile() {
}
public static byte[] getHash(String Filename, String Algorithm) {
try {
MessageDigest d = MessageDigest.getInstance(Algorithm); // Get a hash handler
FileInputStream f = new FileInputStream(Filename); // open file for hashing
byte[] b = new byte[1];
while ( -1 != f.read(b, 0, 1)) // feed the message digester
d.update(b);
f.close();
return d.digest(); // get the final hash and return it
} catch (Exception e) {
System.out.println("Hashing Error " + e.getMessage());
return null;
}
}
}