title: Calculating MD5 Hash (RFC 1321 conform) in Matlab via Java
body: <p>I want to calculate MD5 (or other) file hashes (<a href="http://www.ietf.org/rfc/rfc1321.txt">RFC 1321</a> conform) within MATLAB using the Java-Security-Implementations. Thus I coded</p>
  
  <pre><code>mddigest=java.security.MessageDigest.getInstance('MD5');
  filestream=java.io.FileInputStream(java.io.File(filename));
  digestream=java.security.DigestInputStream(filestream,mddigest);
  md5hash=reshape(dec2hex(typecast(mddigest.digest,'uint8')),1,[])
  </code></pre>
  
  <p>and the routine is working fine. Somehow, the result differs from given tools.<br>
  Maybe there are problems with the file-encoding? Should't MATLAB solve that internally?<br>
  I'd like to reproduce the results, one gets by md5sum (on linux), which equal those from HashCalc (Windows).  </p>