L
Lawrence
Hi all, I use a simple function to create a hash of a file using sha
for
an utility i'm writing.
The function is here :
public static String digest(File file) throws
FileNotFoundException, IOException, NoSuchAlgorithmException {
MessageDigest sha;
sha = MessageDigest.getInstance("sha");
DigestInputStream din = new DigestInputStream(new
BufferedInputStream(new FileInputStream(file)),sha);
while (din.read() != -1){}
din.close();
return sha.digest().toString();
}
I send a file over a network (LAN) between a mac and a windows
computer, both using my application.
I sent zip files, mp3s, jpegs, bmps, txt, tiff, gif, and videos and it
all worked perfectly, but the
outcoming hash is different for the same file.
How weird is that ?Maybe the name of the file matters ?It shouldn't.
for
an utility i'm writing.
The function is here :
public static String digest(File file) throws
FileNotFoundException, IOException, NoSuchAlgorithmException {
MessageDigest sha;
sha = MessageDigest.getInstance("sha");
DigestInputStream din = new DigestInputStream(new
BufferedInputStream(new FileInputStream(file)),sha);
while (din.read() != -1){}
din.close();
return sha.digest().toString();
}
I send a file over a network (LAN) between a mac and a windows
computer, both using my application.
I sent zip files, mp3s, jpegs, bmps, txt, tiff, gif, and videos and it
all worked perfectly, but the
outcoming hash is different for the same file.
How weird is that ?Maybe the name of the file matters ?It shouldn't.