git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@50874 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
40
Data/BulkLoad/EFT/Nominations/java/amHashFile.java
Normal file
40
Data/BulkLoad/EFT/Nominations/java/amHashFile.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package tsdemo;
|
||||
/*
|
||||
* amHashFile.java
|
||||
*
|
||||
* Created on 2007. March 22
|
||||
*
|
||||
*/
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import oracle.sql.BLOB;
|
||||
|
||||
public class amHashFile
|
||||
{
|
||||
/** Creates a new instance of HashFile */
|
||||
public amHashFile() {
|
||||
}
|
||||
|
||||
public static byte[] getHash(oracle.sql.BLOB blobFile, String Algorithm) {
|
||||
try {
|
||||
MessageDigest d = MessageDigest.getInstance(Algorithm); // Get a hash handler
|
||||
//FileInputStream f = new FileInputStream(Filename); // open file for hashing
|
||||
/* get the blob from the documents table as a binary input stream */
|
||||
//oracle.sql.BLOB blob = blobFile;
|
||||
InputStream f = blobFile.getBinaryStream ();
|
||||
//
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user