FileHash
doesn't allow arguments like
FileHash[file,{"CRC32","MD5"}];
A solution could be:
fileHash[file_, hashFormatList_] := FileHash[file, #] & /@ hashFormatList;
but, as far as I understand, that would force Mathematica to read the file as many times as there are elements in hashFormatList
. To avoid this waste of resources I have tried:
Quiet[Remove[fileHash]];
fileHash[file_,hashFormatList_]:=Block[
{return,fileContent},
fileContent=Import[file,"Binary"];
(* or fileContent=BinaryReadList[file]; *)
return=Hash[fileContent,#]&/@hashFormatList;
Return[return];
];
but, surprisingly to me, the MD5 hash of a file differs from the MD5 hash of that file's content. What is the source of this inconsistency?
An answer to the problem of reading the file over and over again would be greatly appreciated also.