Generates a md5 checksum of the file at the specified path.

        `path`
            Path to file for checksum.

        Returns string or ``None``
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
691696
def md5_of_file(abspath):
    
    chunk_size = 1024 * 1024
    m = hashlib.md5()
    with open(abspath, "rb") as f:
        while True:
            data = f.read(chunk_size)
            if not data:
                break
            m.update(data)
    return m.hexdigest()
814909
function(path){
        var hosts = this.hosts,
            count = hosts.length;
        return hosts[parseInt(mod_md5(path),16) % count];
    }
264305
def _md5(path: pathlib.PurePath):
        
        hash_ = hashlib.md5()
        with open(path, 'rb') as f:
            for chunk in iter(lambda: f.read(4096), b''):
                hash_.update(chunk)
        return hash_.hexdigest()
266964
def save_checksum(self, path):
        
        checksum = file_hash(path)
        kv = unitdata.kv()
        kv.set('hardening:%s' % path, checksum)
        kv.flush()
277721
def get_file_md5(filename):
    """"""
    if os.path.exists(filename):
        blocksize = 65536
        try:
            hasher = hashlib.md5()
        except BaseException:
            hasher = hashlib.new('md5', usedForSecurity=False)
        with open(filename, 'rb') as afile:
            buf = afile.read(blocksize)
            while len(buf) > 0:  # pylint: disable=len-as-condition
                hasher.update(buf)
                buf = afile.read(blocksize)
        return hasher.hexdigest()

    return ''
824994
def checksums(self, install):
        
        check_md5(pkg_checksum(install, self.repo), self.tmp_path + install)
136171
def _gen_md5_filehash(fname, *args):
    '''
    
    '''
    _hash = hashlib.md5()
    with salt.utils.files.fopen(fname, 'rb') as f:
        for chunk in iter(lambda: f.read(4096), b''):
            _hash.update(chunk)

    for extra_arg in args:
        _hash.update(six.b(str(extra_arg)))
    return _hash.hexdigest()
79567
def hash_file(file_path, block_size = 65536):
    
    sha = hashlib.sha256()
    with open(file_path, 'rb') as h_file:
        file_buffer = h_file.read(block_size)
        while len(file_buffer) > 0:
            sha.update(file_buffer)
            file_buffer = h_file.read(block_size)
    return sha.hexdigest()
212074
def decrypt_file(path, password=None):
    '''
    
    '''
    global PASSWORD_FILE
    if not password:
        password = PASSWORD_FILE
    if path and not os.path.isfile(path):
        raise SystemExit(_error_codes.get(106))
    query = 'openssl aes-128-cbc -d -salt -in {0} -out {1} -k {2}'
    with hide('output'):
        local(query.format(path, path + '.tar.gz', PASSWORD_FILE))
1042778
def md5sum(file_path, blocksize=65536):
    """"""
    md5 = hashlib.md5()
    with open(file_path, "rb") as f:
        for block in iter(lambda: f.read(blocksize), ""):
            md5.update(block)
    return md5.hexdigest()
906790
def checksum(fpath, hasher=None, asbytes=False):
    """"""
    def blockiter(fpath, blocksize=0x1000):
        with open(fpath, "rb") as afile:
            block = afile.read(blocksize)
            while len(block) > 0:
                yield block
                block = afile.read(blocksize)
    hasher = hasher or hashlib.md5()
    for block in blockiter(fpath):
        hasher.update(block)
    return (hasher.digest() if asbytes else hasher.hexdigest())
416681
def file_to_md5(filename, block_size=8192):
    
    md5 = hashlib.md5()
    with open(filename, 'rb') as f:
        while True:
            data = f.read(block_size)
            if not data:
                break
            md5.update(data)
    return md5.hexdigest()
675313
def get_checksum(self):
        """"""
        with open(self.file, 'rb') as f:
            cs = md5(f.read()).hexdigest()
        return cs
52637
def checksum(path, hashfunc='md5'):
    
    import checksumdir
    hash_func = checksumdir.HASH_FUNCS.get(hashfunc)
    if not hash_func:
        raise NotImplementedError('{} not implemented.'.format(hashfunc))

    if os.path.isdir(path):
        return checksumdir.dirhash(path, hashfunc=hashfunc)

    hashvalues = []
    path_list = glob.glob(path)
    logger.debug("path_list " + str(path_list))
    for path in path_list:
        if os.path.isfile(path):
            hashvalues.append(checksumdir._filehash(path, hashfunc=hash_func))
    logger.debug(str(hashvalues))
    hash = checksumdir._reduce_hash(hashvalues, hashfunc=hash_func)
    return hash
129068
def file_sha1(path):
  
  sha1 = hashlib.sha1()
  with open(path, "rb") as f:
    while True:
      block = f.read(2 ** 10)
      if not block:
        break
      sha1.update(block)
    return sha1.hexdigest()
630806
def file_checksum(fname):
    
    size = os.path.getsize(fname)
    with open(fname, "r+") as f:
        checksum = hashlib.md5(mmap.mmap(f.fileno(), size)).hexdigest()
    return checksum