python/build/verify: add verify_file_digest()

This commit is contained in:
Max Kellermann
2016-12-29 21:40:54 +01:00
parent 3dde62befe
commit 4c650e87fa
2 changed files with 8 additions and 5 deletions

@ -27,3 +27,8 @@ def file_md5(path):
"""Calculate the MD5 checksum of a file and return it in hexadecimal notation."""
return file_digest(hashlib.md5, path)
def verify_file_digest(path, expected_digest):
"""Verify the digest of a file, and return True if the digest matches with the given expected digest."""
return file_md5(path) == expected_digest