From 6180d6ff95baa23432edd87b656af193fc530f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Thu, 16 Jun 2016 16:39:47 +0300 Subject: [PATCH] util md5 added --- opt/ahenk/base/util/util.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/opt/ahenk/base/util/util.py b/opt/ahenk/base/util/util.py index d8d9e99..33eff7b 100644 --- a/opt/ahenk/base/util/util.py +++ b/opt/ahenk/base/util/util.py @@ -9,7 +9,7 @@ import pwd import shutil import stat import subprocess -import sys +import hashlib class Util: @@ -218,3 +218,11 @@ class Util: return False except Exception as e: return False + + @staticmethod + def get_md5_file(fname): + hash_md5 = hashlib.md5() + with open(fname, 'rb') as f: + for chunk in iter(lambda: f.read(4096), b""): + hash_md5.update(chunk) + return str(hash_md5.hexdigest())