Calculate the md5sum of a file and return the hexdigest.
558370
def md5sum(filename):
    """"""
    hash_md5 = hashlib.md5()
    with open(filename, 'rb') as handle:
        for chunk in iter(lambda: handle.read(4096), b''):
            hash_md5.update(chunk)
    return hash_md5.hexdigest()
1222367
def calcMD5(path):
    
    # check that file exists
    if os.path.exists(path) is False:
        yield False
    else:
        command = ['md5sum', path]
        p = Popen(command, stdout = PIPE)
        for line in p.communicate()[0].splitlines():
            yield line.decode('ascii').strip().split()[0]
        p.wait()
        yield False
298184
def md5_string(s):
    
    m = hashlib.md5()
    m.update(s)
    return str(m.hexdigest())
1338350
def checksum_file(scheme, path):
    """"""
    h = getattr(hashlib, scheme)()

    with open(path, 'rb') as f:
        chunk = f.read(65535)
        while chunk:
            h.update(chunk)
            chunk = f.read(65535)
    return h.hexdigest()
171489
public static String calculateMD5(String string) {
		byte[] hash;

		try {
			hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException("Huh, MD5 should be supported?", e);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException("Huh, UTF-8 should be supported?", e);
		}

		StringBuilder hex = new StringBuilder(hash.length * 2);

		for (byte b : hash) {
			int i = (b & 0xFF);
			if (i < 0x10)
				hex.append('0');
			hex.append(Integer.toHexString(i));
		}

		return hex.toString();
	}
1030498
def md5_checksum(file_path, chunk_bytes=4194304):
    """"""

    with open(file_path, "rb") as infile:
        checksum = hashlib.md5()
        while 1:
            data = infile.read(chunk_bytes)
            if not data:
                break
            checksum.update(data)

    return checksum.hexdigest()
1072343
def md5(text):
    """"""

    h = hashlib.md5()
    h.update(_unicode(text).encode("utf-8"))

    return h.hexdigest()
1534
def md5(source):
    
    # fix passing char '+' from source
    source = source.replace("%2B", "+")
    with open(source) as file_to_check:
        data = file_to_check.read()
        return hashlib.md5(data).hexdigest()
869770
def _select_md5sum_arch(self, md5sum, md5sum64):
        
        if md5sum and md5sum64:
            if self.meta.arch == "x86_64":
                return md5sum64
            else:
                return md5sum
        if md5sum:
            return md5sum
        else:
            return md5sum64
525209
def md5_hash_file(fh):
    """"""
    md5 = hashlib.md5()
    while True:
        data = fh.read(8192)
        if not data:
            break
        md5.update(data)
    return md5.hexdigest()
293308
def md5sum_is_current(src_file):
    """"""

    src_md5 = get_md5sum(src_file)

    src_md5_file = src_file + '.md5'
    if os.path.exists(src_md5_file):
        with open(src_md5_file, 'r') as file_checksum:
            ref_md5 = file_checksum.read()

        return src_md5 == ref_md5

    return False
244382
def get_checksum(file):
    
    with open(file, 'rb') as FH:
        contents = FH.read()
    return hashlib.sha256(contents).hexdigest()
1253007
def file_md5(self, file_name):
        """"""
        with open(file_name, "rb") as f:
            file_contents = f.read()
            file_hash = hashlib.md5(file_contents).hexdigest()
        return file_hash
468890
def md5(filename):
    '''  '''

    if not os.path.exists(filename):
        return None
    digest = _md5()
    blocksize = 64 * 1024
    infile = open(filename, 'rb')
    block = infile.read(blocksize)
    while block:
        digest.update(block)
        block = infile.read(blocksize)
    infile.close()
    return digest.hexdigest()
1352244
def get_md5(path):
    
    with open(path,'rb') as f:
        md5obj = hashlib.md5()
        md5obj.update(f.read())
        return md5obj.hexdigest()
    raise FileNotFoundError("Error when get md5 for %s!"%path)
501946
def _get_checksum(path):
    

    # md5 uses a 512-bit digest blocks, let's scale by defined block_size
    _md5 = hashlib.md5()
    chunk_size = 128 * _md5.block_size

    try:
        with open(path, 'rb') as _file:
            for chunk in iter(lambda: _file.read(chunk_size), ''):
                _md5.update(chunk)
        return _md5.hexdigest()

    except IOError:
        return None
1090473
def hash_file(filepath: str) -> str:
    """"""
    md5 = hashlib.md5()
    acc_hash(filepath, md5)
    return md5.hexdigest()