import hashlib


def md5sum(infile):
    """Calculate the md5sum of a file
    """
    # Implementation taken from: http://stackoverflow.com/a/4213255
    md5 = hashlib.md5()
    with open(infile,'rb') as f:
        for chunk in iter(lambda: f.read(128*md5.block_size), b''):
            md5.update(chunk)
    return md5.hexdigest()