You are currently browsing the Chetan Shah’s Blog weblog archives for November, 2009.
- AML (14)
- Foundation (4)
- Personal Finance (21)
- Technology (22)
- 7 Dec 2009: Move securities to Roth Account
- 28 Nov 2009: Leverage Checksum to determine identical files
- 4 Oct 2009: CAMS Certification Preparation
- 30 Aug 2009: Section 311 etc. (ACAMS Notes)
- 24 Aug 2009: FATF Membership Points (ACAMS Notes)
- 22 Aug 2009: Internet Casinos and Prepaid Cards/E-Cash (ACAMS Notes)
- 5 Aug 2009: Spousal IRA
- 15 May 2009: Buying Call Options.
- 7 Jan 2009: Watchlist filtering white paper
- 31 Oct 2008: Autonumber in Microsof Excel (works after inserting rows)
Archive for November 2009
Leverage Checksum to determine identical files
28 Nov 2009 by Chetan Shah.
An easy way to identify if two files are exactly the same or not is by determining the check sum of each file and comparing the check sum. If the check sum for both the files is exactly same then it can said that the two files are identical.
I have written a little java program which determines the check sum of file.
import java.io.FileInputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;
public class Checksum {
public static String computeCheckSum(String fileName) {
try {
FileInputStream stream = new FileInputStream(fileName);
MessageDigest md = MessageDigest.getInstance(”SHA-1″);
DigestInputStream dIS = new DigestInputStream(stream, md);
dIS.on(true);
byte [] b = new byte[1000];
while (dIS.read(b,0,1000) > -1);
byte []signature = md.digest();
//System.out.println(”The signature is :”);
for (int i = 0; i < signature.length; i++) {
System.out.print(signature[i]);
}
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static void main(String [] a) {
Checksum.computeCheckSum(a[0]);
}
}
Posted in Technology | No Comments »
