1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
public static String strEmpreinte(String _strPath, String _strAlgo) throws Exception {
byte[] abBuffer = new byte[65536];
int iNbRead;
InputStream isF = new BufferedInputStream(new FileInputStream(_strPath));
java.security.MessageDigest ODigest = java.security.MessageDigest.getInstance(_strAlgo);
while ((iNbRead = isF.read(abBuffer)) != -1) {
ODigest.update(abBuffer, 0, iNbRead);
}
char[] acHexa = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',};
byte[] abDigest = ODigest.digest();
char acRetour[] = new char[abDigest.length * 2];
for (int i = 0, x = 0; i < abDigest.length; i++) {
acRetour[x++] = acHexa[(abDigest[i] >>> 4) & 0xf];
acRetour[x++] = acHexa[abDigest[i] & 0xf];
}
return new String(acRetour);
} |
Partager