Calculate a sha1 has of either a single file or a list
of files based on the data set by load_data.

@return string
338036
public function get_sha1() {

        if ($this->plugin && $this->editor) {
            $plugin = $this->get_submission_plugin();
            $options = portfolio_format_text_options();
            $options->context = context_module::instance($this->cmid);

            $text = format_text($plugin->get_editor_text($this->editor, $this->sid),
                                $plugin->get_editor_format($this->editor, $this->sid),
                                $options);
            $textsha1 = sha1($text);
            $filesha1 = '';
            try {
                $filesha1 = $this->get_sha1_file();
            } catch (portfolio_caller_exception $e) {
                // No files.
            }
            return sha1($textsha1 . $filesha1);
        }
        return $this->get_sha1_file();
    }
995461
public function getHash()
	{
		$names = array_keys($this->initializers);
		sort($names);
		
		return md5(implode('|', $names));
	}
354835
public function get_sha1() {

        $identifier = 'submission:'.$this->submission->id.'@'.$this->submission->timemodified;

        if ($this->assessments) {
            $ids = array_keys($this->assessments);
            sort($ids);
            $identifier .= '/assessments:'.implode(',', $ids);
        }

        if ($this->multifiles) {
            $identifier .= '/files:'.$this->get_sha1_file();
        }

        return sha1($identifier);
    }
705078
protected function generateChecksumForVersion()
    {
        return sha1(
                sprintf("%s|%s|%s|%s", $this->_secretCode, $this->_merchantID, $this->data->status, substr(strval(time()), 0, 8)
                )
        );
    }
1212501
protected function hashOfFiles($fileList)
    {
        // Get hash based on hash of each file
        $hash = '';
        foreach ($fileList as $file) {
            $absolutePath = Director::getAbsFile($file);
            if (file_exists($absolutePath)) {
                $hash .= sha1_file($absolutePath);
            } else {
                throw new InvalidArgumentException("Combined file {$file} does not exist");
            }
        }
        return sha1($hash);
    }
1095803
def has_data_file(self, sha1hash):  # type: (str) -> bool
        """"""
        folder = os.path.join(self.folder, DATA, sha1hash[0:2])
        hash_path = os.path.join(folder, sha1hash)
        return os.path.isfile(hash_path)
218631
public function findOneBySha1($sha1Hash)
    {
        $query = $this->createQuery();
        $query->matching($query->equals('sha1', $sha1Hash))->setLimit(1);
        /** @var PersistentResource $resource */
        $resource = $query->execute()->getFirst();
        if ($resource === null) {
            /** @var PersistentResource $importedResource */
            foreach ($this->addedResources as $importedResource) {
                if ($importedResource->getSha1() === $sha1Hash) {
                    return $importedResource;
                }
            }
        }

        return $resource;
    }
469597
def sha1sum_file(filename):
    '''
    
    '''
    import hashlib
    import io

    sha1 = hashlib.sha1()
    chunk_size = sha1.block_size * io.DEFAULT_BUFFER_SIZE

    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(chunk_size), b''):
            sha1.update(chunk)
    return sha1.hexdigest()
612551
protected function getDataVersionHash()
    {
        $filter = $this->getPropertyFilter();
        $properties = $filter->getProperties();
        sort($properties);
        
        return sha1(
            static::class . '|' .
            static::VERSION . '|' .
            get_class($filter) . '|' .
            implode(',', $properties)
        );
    }
134385
def _get_by_sha1(self, sha1):
        
        for image_part in self._image_parts:
            if image_part.sha1 == sha1:
                return image_part
        return None
645346
public function getHash()
	{
		if (is_null($this->hash) || filemtime($this->path) > $this->hashTimestamp) {
			$this->hash = sha1_file($this->path);
			$this->hashTimestamp = filemtime($this->path);
		}
		return $this->hash;
	}
302740
public function calculateHash(): string
    {
        return EntityUtils::calculateHashOfArray([
            $this->name,
            $this->mainModName,
            $this->loadedModNames,
            $this->loadedOptionalModNames,
        ]);
    }
463426
public function get_sha1() {
        // in the case that we're exporting a subclass of 'file' and we have a singlefile,
        // then we're not exporting any metadata, just the file by itself by mimetype.
        if ($this->exporter->get('format') instanceof portfolio_format_file && $this->singlefile) {
            return $this->get_sha1_file();
        }
        // otherwise we're exporting some sort of multipart content so use the data
        $str = '';
        foreach ($this->records as $record) {
            foreach ($record as $data) {
                if (is_array($data) || is_object($data)) {
                    $keys = array_keys($data);
                    $testkey = array_pop($keys);
                    if (is_array($data[$testkey]) || is_object($data[$testkey])) {
                        foreach ($data as $d) {
                            $str .= implode(',', (array)$d);
                        }
                    } else {
                        $str .= implode(',', (array)$data);
                    }
                } else {
                    $str .= $data;
                }
            }
        }
        return sha1($str . ',' . $this->exporter->get('formatclass'));
    }
948700
public function getHash()
	{
		if ($this->hash == null) {
			$this->requestBody();
			$this->hash = sha1_file($this->bodyTempFile);
		}
		return $this->hash;
	}
985587
def sha1(filename):
    """"""
    filename = unmap_file(filename)
    if filename not in file_cache:
        cache_file(filename)
        if filename not in file_cache:
            return None
        pass
    if file_cache[filename].sha1:
        return file_cache[filename].sha1.hexdigest()
    sha1 = hashlib.sha1()
    for line in file_cache[filename].lines['plain']:
        sha1.update(line.encode('utf-8'))
        pass
    file_cache[filename].sha1 = sha1
    return sha1.hexdigest()
1193913
private function compareConfigFile()
    {
        $cachePath = INITIALLY_RPC_ROOT_PATH . "/src";
        $cacheFile = $cachePath . "/info.cache";
        Util::createDirIfNotExists($cachePath);
        $configSha1 = sha1_file($this->configFile);
        if (!is_file($cacheFile)) {
            if (!@file_put_contents($cacheFile, $configSha1)) {
                throw new InitiallyRpcException("write config file md5 failed");
            }

            $oldConfigSha1 = $configSha1;
        } else {
            $oldConfigSha1 = file_get_contents($cacheFile);
            if ($configSha1 != $oldConfigSha1 && !@file_put_contents($cacheFile, $configSha1)) {
                throw new InitiallyRpcException("write config file md5 failed");
            }
        }

        return $configSha1 == $oldConfigSha1;
    }
1183941
protected function generateReusableHash(): string
    {
        $data = $this->data;
        $this->data = null;  // https://github.com/yiisoft/yii2/issues/3052
        $key = sha1(serialize($this));
        $this->data = $data;
        return $key;
    }