buildgrid.server.utils.digests module

class buildgrid.server.utils.digests.HashableDigest(hash: str, size_bytes: int)

Bases: object

hash: str
size_bytes: int
to_digest() Digest
buildgrid.server.utils.digests.get_hash_type() int

Returns the hash type.

buildgrid.server.utils.digests.create_digest(bytes_to_digest: bytes) Digest

Computes the Digest of a piece of data.

The Digest of a data is a function of its hash and size.

Parameters:

bytes_to_digest (bytes) – byte data to digest.

Returns:

The Digest for the given byte data.

Return type:

Digest

buildgrid.server.utils.digests.parse_digest(digest_string: str) Digest | None

Creates a Digest from a digest string.

A digest string should alway be: {hash}/{size_bytes}.

Parameters:

digest_string (str) – the digest string.

Returns:

The Digest read from the string or None if

digest_string is not a valid digest string.

Return type:

Digest

buildgrid.server.utils.digests.validate_digest_data(digest: Digest, data: bytes) bool

Validate that the given digest corresponds to the given data.