Hi,
Hier das Coding:
Hier das Coding:
Java:
public String ProcessMessage(File file, SapfschkMain main) {
try {
// int length = 1048576;
int length = 4194304;
int offset = 0;
FileInputStream fin = new FileInputStream(file);
BufferedInputStream bin = new BufferedInputStream(fin);
MessageDigest md = MessageDigest.getInstance("MD5");
StringBuffer buffer = new StringBuffer();
while (true) {
int iBuf = bin.available();
System.err.println(iBuf);
if (iBuf < length) {
length = iBuf;
}
byte[] result = new byte[length];
bin.read(result, offset, length);
md.update(result, offset, length);
if (length == iBuf) {
break;
}
}
byte[] printTest = md.digest();
for (int i = 0; i < printTest.length; i++) {
String temp = Integer.toHexString(printTest[i]);
if (temp.length() == 1) {
temp = "0" + temp;
buffer.append(temp);
} else if (temp.length() > 2) {
buffer.append(temp.substring(temp.length() - 2));
} else
buffer.append(temp);
}
bin.close();
fin.close();
return buffer.toString();
} catch (NoSuchAlgorithmException e) {
if (main != null) {
main.addLog(e.getMessage());
}
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
Zuletzt bearbeitet von einem Moderator: