Skip to main content


Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How-to: Copy the MD5 checksum to a tag and compare it (Read 2275 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How-to: Copy the MD5 checksum to a tag and compare it

How to copy the built-in FLAC MD5 audio checksum to the Comment tag and verify that it matches, using Mp3tag.
This is primarily intended to be used for [prior to] conversions from FLAC to FLAC (usually changing compression levels) or from FLAC to any lossless format and back to FLAC. As long as the Comment tag is carried over through the conversions, you have the confirmation that the audio data stayed the same.

Step 0 (optional) - Display the MD5 checksum in a column:
1. Right click on the top of the columns, select "Customize columns..." and make a New column.
2. Name: MD5 and Value: %_md5audio%.
You should now see the MD5 values for all FLAC files.

Step 1 - Copy the MD5 checksum to the Comment tag:
1. Select the track(s).
2. Click on the "Tag - Tag" button in the toolbar.
3. Field: COMMENT and Format string: %comment% '['MD5: %_md5audio%']'.
This will add the checksum at the end of the existing comments/content, like [MD5: 42B36D5....].

Step 2 - Check if the built-in MD5 checksum is included in the Comment tag:
1. Make a New column.
2. Name: MD5 check. Value: $ifgreater($strstr(%comment%,%_md5audio%),0,OK,ERROR).
If the exact MD5 checksum of a file exists also in the Comment tag, the column will show OK, otherwise it will show ERROR. The matching is case-sensitive. If you have a big list of files you can sort by column to separate the OKs and the ERRORs.

That's it. So far it's been working as intended for me, but let me know if you encounter any problems or have any suggestions.
Using the Comment tag for this might be less than ideal, because there's often content there. OTOH it seems like a safe option that should work across various audio formats and software without breaking stuff.

Re: How-to: Copy the MD5 checksum to a tag and compare it

Reply #1
On using some other tag instead of the Comment... Apparently the FLAC (Vorbis) tagging system allows creating custom tags without breaking the FLAC format. So you could copy that MD5 data into your own custom tag, which could be called MD5CUSTOMTAG, for example.
In that case you might as well copy the MD5 value directly without any brackets and you can have a simpler formula in Mp3tag, like $if($eql(%MD5CUSTOMTAG%,%_md5audio%),OK,ERROR).

I converted such a FLAC to WavPack, MP3, AAC and Opus with Foobar and the custom tag was transferred as well and the files appear to work fine in a couple of Windows programs that I tried.
The only question is whether such files would work fine everywhere. I remember a case where a hardware MP3 player couldn't play MP3 files if they contained the disc number, for example, that's why I'm a bit careful.
But since the custom tag can be removed later, I think it's not a big deal. If someone knows more about this, let me know.

Re: How-to: Copy the MD5 checksum to a tag and compare it

Reply #2
TagScanner now also has a FLAC MD5 placeholder function. Here's how to copy that MD5 data to a new "custom" tag and make a comparison column.

Step 0 (optional) - Display the built-in MD5 data and your own new MD5-containing tag, each in its own column:
1. Right click -> Add Column.
2. Give it a Name and in Field/Pattern enter %_flac_md5%.
3. Make a column also for the new/custom tag. In the Field/Pattern enter, for example, %MD5TAG%.

Step 1 - Copy the MD5 checksum data for the selected FLAC file(s) to the new tag:
1. In the toolbar, click on "Format value from other fields...".
2. In Field, enter MD5TAG and in Pattern enter %_flac_md5%.

Step 2 - Verify that the two values match, using a new column with a function:
1. Create a new column, give it a name (like MD5-check) and in Field/Pattern enter $if($equal(%MD5TAG%,%_flac_md5%),OK,ERROR).
If the two fields match, you should see OK, otherwise it says ERROR. It says ERROR also if you haven't copied the MD5 data to the custom tag yet.

In the mean time, I also tried playing files with a custom tag like this (MD5TAG) in a few simple hardware players and there were no issues, even with MP3s. So I would recommend using this method instead of copying this data to the Comment tag or whatever. It's tidier and in the worst case you can still remove the tag.


Re: How-to: Copy the MD5 checksum to a tag and compare it

Reply #3
I'm updating the MD5 checking command (for the column in Mp3tag and TagScanner), for two reasons:
First, to distinguish between files that don't have a MD5 checksum copy and the files where the copy is different.

And second, to identify files that don't have the built-in MD5 value/signature (it was unset in the STREAMINFO). Such files can be produced, for example, by encoding with --no-md5-sum or, for example, when ripping from Qobuz. And I found some very old files that didn't have it, which were almost certainly encoded so by accident, or by a bug in the software.
Mp3tag and TagScanner show the MD5 value for such files as 00000000000000000000000000000000.

Also, from now on I'm calling the custom MD5 checksum tag MD5COPY, which should be less confusing.

For Mp3tag:
$if($eql(00000000000000000000000000000000,%_md5audio%),NO MD5!,$if($eql($len(%MD5COPY%),0),no copy,$if($eql(%MD5COPY%,%_md5audio%),copy OK,ERROR!)))

For TagScanner:
$if($equal(00000000000000000000000000000000,%_flac_md5%),NO MD5!,$if($equal($len(%MD5COPY%),0),no copy,$if($equal(%MD5COPY%,%_flac_md5%),copy OK,ERROR!)))

So, now there are 4 possible outputs:
1. no copy — there is no copy of the built-in MD5 checksum (MD5COPY has 0 data).
2. copy OK — there's a copy and it's the same as the built-in MD5.
3. ERROR! — there's a copy, but it doesn't match the built-in MD5.
4. NO MD5! — the built-in MD5 checksum doesn't exist (its value is 00000000000000000000000000000000).