What is MD5 checksum and how can I use it?

An MD5 checksum is a 32-character hexadecimal number that is computed on a file. If two files have the same MD5 checksum value, then there is a high probability that the two files are the same, something like a fingerprint of the file. The MD5 checksum is depending on both the file content and the file size. This feature can be useful both for comparing files and their integrity control.

The MD5 checksum is good to use when you making a backup of a file or your server or for example. It would be very handy to get the MD5 value on your original file, so you can compare it with the copy whenever you move it or download it from a cloud storage or similar. So you know that the file is complete and nothing is wrong with it. Lets say that you upload your original file somewhere and then download it to another system, if the MD5 Hash is the same on the copy as on the original file, nothing is wrong. But if is does not match, you know right there that something is wrong with the copy.

Here we will show you how to get the MD5 checksum for files after transcoding to be able to verify that nothing was lost in the file on the way. You can add a job step that verifies the MD5 checksum on the output after transfer. This should be placed in the step before the "Finalizing" step;

var metadata = api.path('storage/file/'+job.getData('fileId')).get().metadata.field;
var md5sum;
for (var i = 0; i < metadata.length; i++) {
    if (metadata[i].key == 'hash-MD5')
        md5sum = metadata[i].value;
}
if (!md5sum) {
    job.fail('could not verify transfer, source file does not have MD5 checksum');
}
var destinationmd5 = shell.exec('md5sum',api.path('storage/file/'+job.getData('destinationFileId')).get().uri[0].replace(/^file:\/\//, "")).output.split(' ')[0];
if (md5sum != destinationmd5) {
    job.fail('md5 mismatch '+md5sum+' != '+destinationmd5);
}
CODE

You should now get a MD5 checksum value after a finished job, that you can compare to the input file.

How to add job tasks;

http://apidoc.vidispine.com/latest/job/job.html#job-tasks

More about MD5 Hash;

https://en.wikipedia.org/wiki/MD5