コード例 #1
0
def obj_sha(type, chunks):
    """Compute the SHA for a numeric type and object chunks."""
    sha = make_sha()
    sha.update(object_header(type, chunks_length(chunks)))
    for chunk in chunks:
        sha.update(chunk)
    return sha.digest()
コード例 #2
0
def iter_sha1(iter):
    """Return the hexdigest of the SHA1 over a set of names.

    :param iter: Iterator over string objects
    :return: 40-byte hex sha1 digest
    """
    sha1 = make_sha()
    for name in iter:
        sha1.update(name)
    return sha1.hexdigest()
コード例 #3
0
ファイル: objects.py プロジェクト: Einarin/Observatory
 def sha(self):
     """The SHA1 object that is the name of this object."""
     if self._sha is None or self._needs_serialization:
         # this is a local because as_raw_chunks() overwrites self._sha
         new_sha = make_sha()
         new_sha.update(self._header())
         for chunk in self.as_raw_chunks():
             new_sha.update(chunk)
         self._sha = new_sha
     return self._sha
コード例 #4
0
ファイル: objects.py プロジェクト: rcos/Observatory-retired
 def sha(self):
     """The SHA1 object that is the name of this object."""
     if self._sha is None or self._needs_serialization:
         # this is a local because as_raw_chunks() overwrites self._sha
         new_sha = make_sha()
         new_sha.update(self._header())
         for chunk in self.as_raw_chunks():
             new_sha.update(chunk)
         self._sha = new_sha
     return self._sha
コード例 #5
0
 def __init__(self, read_all, read_some=None):
     self.read_all = read_all
     if read_some is None:
         self.read_some = read_all
     else:
         self.read_some = read_some
     self.sha = make_sha()
     self._offset = 0
     self._rbuf = StringIO()
     # trailer is a deque to avoid memory allocation on small reads
     self._trailer = deque()
コード例 #6
0
    def calculate_checksum(self):
        """Calculate the checksum for this pack.

        :return: 20-byte binary SHA1 digest
        """
        s = make_sha()
        self._file.seek(0)
        todo = self._get_size() - 20
        while todo > 0:
            x = self._file.read(min(todo, 1<<16))
            s.update(x)
            todo -= len(x)
        return s.digest()
コード例 #7
0
    def calculate_checksum(self):
        """Calculate the SHA1 checksum over this pack index.

        :return: This is a 20-byte binary digest
        """
        return make_sha(self._contents[:-20]).digest()
コード例 #8
0
 def __init__(self, f):
     self.f = f
     self.sha1 = make_sha("")
コード例 #9
0
ファイル: objects.py プロジェクト: Einarin/Observatory
 def _make_sha(self):
     ret = make_sha()
     ret.update(self._header())
     for chunk in self.as_raw_chunks():
         ret.update(chunk)
     return ret
コード例 #10
0
ファイル: objects.py プロジェクト: rcos/Observatory-retired
 def _make_sha(self):
     ret = make_sha()
     ret.update(self._header())
     for chunk in self.as_raw_chunks():
         ret.update(chunk)
     return ret