Is there a way to add comments in md5 file?

739 views Asked by At

I have a library of files. Each file has each own *.md5 file (created by Total Commander) with md5 hash and additional *.txt file with some comments.

Is there any way to move these comments from *.txt file to *.md5 file (and delete *.txt file) in a form of some internal block of comments (like using "rem" in Windows batch files or "<! --" and "-- >" in HTML) so I could still use *.md5 files to check the hashes?

2

There are 2 answers

2
Danny On BEST ANSWER

Any line beginning with ; in .md5 files is a comment.

3
mivk On

Use # as a comment character.

The accepted answers suggesting ; works with Total Commander in Windows, but gives an error with GNU's md5sum, and probably also with other tools:

md5sum: WARNING: 1 line is improperly formatted

But both Total Commander and the standard md5sum accept the usual Unix comment character # instead. So use that.


Additional notes:

While Windows has traditionally been using ; as a comment character, particularly in it's older .ini files, Unix mostly uses # in it's shells and most scripting environments. (and Windows too now, in Powershell).

Since (arguably) most uses of md5 are on Unix machines where tools like md5 on Macs or md5sum on Linux come with the OS, the traditional # seems a bit safer.

Note also that TC on Windows accepts .md5 files with Unix "LF" line endings (or "/" as path separator), but the Unix tools cannot check md5 files using Windows "CRLF" line endings (or "\" in paths).

However, there is nothing about comments in the original RFC 1321, and there doesn't seem to be any official mention of using comments in .md5 files...