Return the size of a blob in the registry given the hash of its content.

        :param digest: Hash of the blob's content (prefixed by ``sha256:``).
        :type digest: str

        :rtype: long
        :returns: Whether the blob exists.
551009
def blob_size(self, digest):
        
        r = self._request('head', 'blobs/' + digest)
        return long(r.headers['content-length'])
259562
def read(self, chunk_size=None):
        
        if chunk_size:
            data = self.content[self.pos:self.pos + chunk_size]
            self.pos += len(data)
            return data
        else:
            return self.content
496523
def thumbprint(digest_type = nil)
      digest_type ||= 'SHA256'
      thumbprint_binary = JOSE.encode(to_thumbprint_map)
      return JOSE.urlsafe_encode64(OpenSSL::Digest.new(digest_type).digest(thumbprint_binary))
    end
468890
def md5(filename):
    '''  '''

    if not os.path.exists(filename):
        return None
    digest = _md5()
    blocksize = 64 * 1024
    infile = open(filename, 'rb')
    block = infile.read(blocksize)
    while block:
        digest.update(block)
        block = infile.read(blocksize)
    infile.close()
    return digest.hexdigest()
200724
def long_hash(*buffers):
    
    hashed = hashlib.sha256()
    for buffer in buffers:
        hashed.update(buffer)
    return to_ascii(hashed.digest())[0:43]
1237290
def digest(self):
        
        if self._digest is None:
            if self._buf:
                self._add_block(self._buf)
                self._buf = EMPTY
            ctx = self._blake2s(0, 1, True)
            for t in self._thread:
                ctx.update(t.digest())
            self._digest = ctx.digest()
        return self._digest
693670
def sha256(self):
        

        if self._sha256 is None:
            self._sha256 = hashlib.sha256(self.dump()).digest()
        return self._sha256
1198041
def compare_hexdigests( digest1, digest2 ):
    """"""
    # convert to 32-tuple of unsighed two-byte INTs
    digest1 = tuple([int(digest1[i:i+2],16) for i in range(0,63,2)])
    digest2 = tuple([int(digest2[i:i+2],16) for i in range(0,63,2)])
    bits = 0
    for i in range(32):
        bits += POPC[255 & digest1[i] ^ digest2[i]]
    return 128 - bits
1151477
def md5hash(self):
        """"""
        digest = hashlib.md5(self.content).digest()
        return b64_string(digest)
143552
def _pkcs1imify(self, data):
        
        SHA1_DIGESTINFO = '\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14'
        size = len(util.deflate_long(self.n, 0))
        filler = '\xff' * (size - len(SHA1_DIGESTINFO) - len(data) - 3)
        return '\x00\x01' + filler + '\x00' + SHA1_DIGESTINFO + data
24263
def digest(self, data=None):
        
        if self.digest_finalized:
            return self.digest_out.raw[:self.digest_size]
        if data is not None:
            self.update(data)
        self.digest_out = create_string_buffer(256)
        length = c_long(0)
        result = libcrypto.EVP_DigestFinal_ex(self.ctx, self.digest_out,
                                              byref(length))
        if result != 1:
            raise DigestError("Unable to finalize digest")
        self.digest_finalized = True
        return self.digest_out.raw[:self.digest_size]
106022
def digest_size(self):
        ""
        if getattr(self, '_fobj', None) is not None:
            return self._fobj.digest_size
        else:
            return hashlib.new(self._algorithms[-1]).digest_size
1314721
def _const_compare_digest_backport(a, b):
    
    result = abs(len(a) - len(b))
    for l, r in zip(bytearray(a), bytearray(b)):
        result |= l ^ r
    return result == 0
195698
def Size(self):
        
        corrected_hashes = list(map(lambda i: UInt256(data=binascii.unhexlify(i)), self.HashStart))
        return GetVarSize(corrected_hashes) + self.hash_stop.Size
867017
def p2pkh?
      return false unless chunks.size == 5
      [OP_DUP, OP_HASH160, OP_EQUALVERIFY, OP_CHECKSIG] ==
          (chunks[0..1]+ chunks[3..4]).map(&:ord) && chunks[2].bytesize == 21
    end
279451
def compare_digest(a, b):
    """"""
    py_version = sys.version_info[0]
    if py_version >= 3:
        return _compare_digest_py3(a, b)
    return _compare_digest_py2(a, b)
980494
def get_image(self, digest, blob, mime_type, index, size=500):
        """"""
        # Special case, for now (XXX).
        if mime_type.startswith("image/"):
            return ""

        cache_key = f"img:{index}:{size}:{digest}"
        return self.cache.get(cache_key)