DigestInputStream - MD5 different results
843810Jun 9 2003 — edited Jun 12 2003hi,
I saw a little example of DigestInputStream in the Internet, I tested it using a text-file , read it using :
while(dis.read(buffer) > 0)
;
Then I called the digest method and afterwards called an toHexString() method. After that I called md5sum and calculated the checksum of the same text file, but the result was different.
1) Can that be possible ?
2) If yes, how ?
SO far,
strychnin1
here is the code (without exception handling etc.)
FileInputStream fis = new FileInputStream(filename);
DigestInputStream dis = new DigestInputStream(fis,md);
byte[] buffer = new byte[1024];
while(dis.read(buffer) > 0)
;
byte[] digest = md5.digest();
fis.close();
Then I called the tohexstring() method, but that method is correct and can't be the reason for it.