diff --git a/blivet/util.py b/blivet/util.py index 5c1385817..6534918bb 100644 --- a/blivet/util.py +++ b/blivet/util.py @@ -9,6 +9,7 @@ import sys import tempfile import uuid +import hashlib from decimal import Decimal from contextlib import contextmanager @@ -357,6 +358,18 @@ def insert_colons(a_string): else: return suffix +def md5_file(filename): + + f = open(filename, "rb") + md5 = hashlib.md5() + + block = f.read(65536) + while block: + md5.update(block) + block = f.read(65536) + + return md5.hexdigest() + class ObjectID(object): """This class is meant to be extended by other classes which require an ID which is preserved when an object copy is made.