Bastian Ebeling Bastian Ebeling - 1 year ago 127
Java Question

Calculating MD5 Hash (RFC 1321 conform) in Matlab via Java

I want to calculate MD5 (or other) file hashes (RFC 1321 conform) within MATLAB using the Java-Security-Implementations. Thus I coded'MD5');;,mddigest);

and the routine is working fine. Somehow, the result differs from given tools.

Maybe there are problems with the file-encoding? Should't MATLAB solve that internally?

I'd like to reproduce the results, one gets by md5sum (on linux), which equal those from HashCalc (Windows).

Answer Source

There is two problems:

  1. You don't read the file.
  2. You have to transpose the matrix before reshape it.

This code works:

mddigest   ='MD5'); 
filestream =; 
digestream =,mddigest);

while( ~= -1) end

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download