:return: The SHA-1 info hash of the torrent. Useful for generating
            magnet links.

        .. note:: ``generate()`` must be called first.
343763
def info_hash(self):
        
        if getattr(self, '_data', None):
            return sha1(bencode(self._data['info'])).hexdigest()
        else:
            raise exceptions.TorrentNotGeneratedException
1123208
def hash_file(filename):
    
    hasher = hashlib.sha1()
    with open(filename, 'rb') as f:
        buf = f.read(65536)
        while len(buf) > 0:
            hasher.update(buf)
            buf = f.read(65536)

    return hasher.hexdigest()
95522
def get_hash_of_dirs(directory):
    
    import hashlib
    sha = hashlib.sha512()
    if not os.path.exists(directory):
        return -1

    for root, _, files in os.walk(directory):
        for name in files:
            filepath = local.path(root) / name
            if filepath.exists():
                with open(filepath, 'rb') as next_file:
                    for line in next_file:
                        sha.update(line)
    return sha.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
1010930
def get_hash(self):
        
        if self._hash is None:
            self._hash = self._source.get_hash(self._handle).strip()
        return self._hash
693670
def sha256(self):
        

        if self._sha256 is None:
            self._sha256 = hashlib.sha256(self.dump()).digest()
        return self._sha256
1342078
def make_hash_id():
    
    today = datetime.datetime.now().strftime(DATETIME_FORMAT)
    return hashlib.sha1(today.encode('utf-8')).hexdigest()
290070
def get_fixtures_file_hash(all_fixture_paths: Iterable[str]) -> str:
    
    hasher = hashlib.md5()
    for fixture_path in sorted(all_fixture_paths):
        with open(fixture_path, 'rb') as fixture_file:
            hasher.update(fixture_file.read())
    return hasher.hexdigest()
431199
def sha1(s):
    
    h = hashlib.new('sha1')
    h.update(s)
    return h.hexdigest()
943306
def get_hash(self, length=HASH_LENGTH):
        

        data_hash = ""
        if not self.data_str:
            return data_hash

        encoded_data_str = self.data_str
        if sys.version_info.major == 2:
            # In Py2, only unicode needs to be encoded.
            if isinstance(self.data_str, unicode):
                encoded_data_str = self.data_str.encode('utf-8')
        else:
            # data_str should always be unicode on python 3
            encoded_data_str = self.data_str.encode('utf-8')

        data_hash = hashlib.sha1(encoded_data_str).hexdigest()

        return data_hash[:length]
74954
def files(self):
        
        info = self.metainfo['info']
        if 'length' in info:    # Singlefile
            yield info['name']
        elif 'files' in info:   # Multifile torrent
            rootdir = self.name
            for fileinfo in info['files']:
                yield os.path.join(rootdir, os.path.join(*fileinfo['path']))
720760
def sha1_hexdigest(self):
        # type: () -> str
        
        if self._sha1_hexdigest is None:
            self._sha1_hexdigest = hashlib.sha1(self._pem_bytes).hexdigest()

        return self._sha1_hexdigest
458962
def sha1_digest(instr):
    '''
    
    '''
    if six.PY3:
        b = salt.utils.stringutils.to_bytes(instr)
        return hashlib.sha1(b).hexdigest()
    return hashlib.sha1(instr).hexdigest()
363437
def SHA1_file(filepath, extra=b''):
    
    h = hashlib.sha1()
    with io.open(filepath, 'rb') as f:
        for chunk in iter(lambda: f.read(h.block_size), b''):
            h.update(chunk)
    h.update(extra)
    return h.hexdigest()
478172
def build_sha1(self):
        
        # pylint: disable=len-as-condition
        if len(self.dutinformation) > 0 and (self.dutinformation.get(0).build is not None):
            return self.dutinformation.get(0).build.sha1
        return None
273493
def get_available_hashes():
    
    if sys.version_info >= (3,2):
        return hashlib.algorithms_available
    elif sys.version_info >= (2,7) and sys.version_info < (3,0):
        return hashlib.algorithms
    else:
        return 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'
79156
def to_hash
      {
        :installer => installer,
        :installer_arguments => installer_arguments,
        :iso_path => iso_path,
        :iso_upload_path => iso_upload_path,
        :iso_mount_point => iso_mount_point,
        :auto_update => auto_update,
        :auto_reboot => auto_reboot,
        :no_install => no_install,
        :no_remote => no_remote,
        :yes => yes
      }
    end