Returns a SHA256 hash of the contents of ``path`` combined with the Arca version.
486489
def hash_file_contents(requirements_option: RequirementsOptions, path: Path) -> str:
        
        return hashlib.sha256(path.read_bytes() + bytes(
            requirements_option.name + arca.__version__, "utf-8"
        )).hexdigest()
1271036
def _hash_of_file(path, algorithm):
    """"""
    with open(path, 'rb') as archive:
        hash = hashlib.new(algorithm)
        for chunk in read_chunks(archive):
            hash.update(chunk)
    return hash.hexdigest()
546653
def get_image_file_hash(image_path):
    '''
    '''
    hasher = hashlib.md5()
    with open(image_path, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            hasher.update(chunk)
    return hasher.hexdigest()
220073
def hash_file(filename):
    
    sha256 = hashlib.sha256()
    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(8192), b''):
            sha256.update(chunk)
    return 'sha256:' + sha256.hexdigest()
1052305
def hash(self):
        """"""
        if self._hash is None:
            tohash = [self.path.name]
            # Hash a maximum of ~1MB of the hdf5 file
            tohash.append(hashfile(self.path, blocksize=65536, count=20))
            self._hash = hashobj(tohash)
        return self._hash
71118
def sha1_of_file(filepath):
    
    import hashlib
    try:
        with open(filepath, 'rb') as file_to_hash:
            return hashlib.sha1(file_to_hash.read()).hexdigest()
    except:  # pylint: disable=bare-except
        return None
1206893
def rehash(path, blocksize=1 << 20):
    # type: (str, int) -> Tuple[str, str]
    """"""
    h = hashlib.sha256()
    length = 0
    with open(path, 'rb') as f:
        for block in read_chunks(f, size=blocksize):
            length += len(block)
            h.update(block)
    digest = 'sha256=' + urlsafe_b64encode(
        h.digest()
    ).decode('latin1').rstrip('=')
    # unicode/str python2 issues
    return (digest, str(length))
144170
def add_asset_hashes(self, path='dist/assets'):
		
		for fullpath in _listfiles(os.path.join(self.root_path, path)):
			relpath = fullpath.replace(self.root_path + '/' + path + '/', '')
			md5sum = hashlib.md5(open(fullpath, 'rb').read()).hexdigest()
			LOG.debug('MD5 of %s (%s): %s', fullpath, relpath, md5sum)
			self.asset_hash[relpath] = md5sum
1281777
def checksum(self, path, hashtype='sha1'):
        """"""
        return self._handler.checksum(hashtype, posix_path(path))
994540
def get_sha(path=None, log=None, short=False, timeout=None):
    
    # git_command = "git rev-parse HEAD {}".format(repo_name).split()
    # git_command = "git rev-parse HEAD".split()
    git_command = ["git", "rev-parse"]
    if short:
        git_command.append("--short")
    git_command.append("HEAD")

    kwargs = {}
    if path is not None:
        kwargs['cwd'] = path
    if timeout is not None:
        kwargs['timeout'] = timeout

    if log is not None:
        log.debug("{} {}".format(git_command, str(kwargs)))

    sha = subprocess.check_output(git_command, **kwargs)
    try:
        sha = sha.decode('ascii').strip()
    except:
        if log is not None:
            log.debug("decode of '{}' failed".format(sha))

    return sha
211369
def get_hashes(path, exclude=None):
    '''
    
    '''
    out = {}
    for f in Path(path).rglob('*'):
        if f.is_dir():
            # We want to watch files, not directories.
            continue
        if exclude and re.match(exclude, f.as_posix()):
            retox_log.debug("excluding '{}'".format(f.as_posix()))
            continue
        pytime = f.stat().st_mtime
        out[f.as_posix()] = pytime
    return out
525135
def read_checksum_digest(path, checksum_cls=hashlib.sha256):
  """"""
  checksum = checksum_cls()
  size = 0
  with tf.io.gfile.GFile(path, "rb") as f:
    while True:
      block = f.read(io.DEFAULT_BUFFER_SIZE)
      size += len(block)
      if not block:
        break
      checksum.update(block)
  return checksum.hexdigest(), size
882625
def _get_sha256_digest(self, content):
        
        content_sha256 = base64.b64encode(SHA256.new(content).digest())
        return 'SHA256=' + content_sha256
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()
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
244382
def get_checksum(file):
    
    with open(file, 'rb') as FH:
        contents = FH.read()
    return hashlib.sha256(contents).hexdigest()
550478
def hash_dir(path):
    """"""
    dir_hash = {}

    for root, dirs, files in os.walk(path, topdown=False):
        f_hash = ((f, hash_file(join(root, f))) for f in files)
        d_hash = ((d, dir_hash[join(root, d)]) for d in dirs)
        # split+join normalizes paths on Windows (note the imports)
        dir_hash[join(*split(root))] = _mktree(f_hash, d_hash)

    return dir_hash[path]