I need to generate an md5 hash for a list of tif
and jpg
images.The hash must be inserted in an XML file with metadata about each image, which will be used for the digitalisation of the document.The use of the md5 hash was not my decision, but a formal requirement of a standard based on the Dublin Core for the digitalisation of these kinds of documents. Xml file, md5 tag is underlined
I am currently generating each md5 hash using Windows built-in Certutil program from the command prompt.
My question is simple: am I doing this right?I know the process is slow, but the list is short.
Certutil hash function
Best Answer
it looks OK, remember that specifying hash algorithm (MD5) works from windows 7 and up (older windows throw and error) and must be in uppercase. You can also add find /v "hash" to get only hash itselflike this
certUtil -hashfile pathToFileToCheck MD5 | find /v "hash"
for example, running on windows 8, i got this output
C:\Users\xxxx\Documents>certutil -hashfile innfo MD5MD5 hash of file innfo:67 4b ba 79 42 32 d6 24 f0 56 91 b6 da 41 34 6dCertUtil: -hashfile command completed successfully.
and with find /v "hash" i've got
C:\Users\xxxx\Documents>certutil -hashfile innfo MD567 4b ba 79 42 32 d6 24 f0 56 91 b6 da 41 34 6d
the find trick is to exclude (/v parameter) following string "hash" and you have to specify the string in double quotes.As the first and last line around hash itself contain word hash, you have clean output
my version works from cmd not powershell
I often need to create a hash file to place on an FTP service.These hash files must contain the name of the original file to allow automatic verification that is done by various tools.For example, if you have a file named foo.txt, it is necessary to have a file foo.txt.md5 with the following content:
a3713593c5edb65c8287eb6ff9ec4bc0 *foo.txt
The following batch does the job
for %%a in (%1) do set filename=%%~nxa@certutil -hashfile "%1" md5 | find /V "hash" >temp.txtfor /f "delims=" %%i in (temp.txt) do set hash=%%iecho %hash% *%filename%>%1.md5del temp.txt
You can replace md5 for sha256 or 512 if you need. The CERTUTIL supports.