Gordian Envelope TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Class Digest

    Implements

    • DigestProvider
    • CborTaggedEncodable
    • CborTaggedDecodable<Digest>
    • UREncodable
    Index

    Properties

    DIGEST_SIZE: 32

    Methods

    • Get the digest data.

      Returns Uint8Array

    • Create a Digest from a 32-byte array.

      Parameters

      • data: Uint8Array

      Returns Digest

    • Create a Digest from data, validating the length. Alias for fromData for compatibility with Rust API.

      Parameters

      • data: Uint8Array

      Returns Digest

    • Create a Digest from hex string.

      Parameters

      • hex: string

      Returns Digest

      Error if the hex string is not exactly 64 characters.

    • Compute SHA-256 digest of data (called "image" in Rust).

      Parameters

      • image: Uint8Array

        The data to hash

      Returns Digest

    • Compute SHA-256 digest from multiple data parts.

      The parts are concatenated and then hashed.

      Parameters

      • imageParts: Uint8Array<ArrayBufferLike>[]

        Array of byte arrays to concatenate and hash

      Returns Digest

    • Compute SHA-256 digest from an array of Digests.

      The digest bytes are concatenated and then hashed.

      Parameters

      • digests: Digest[]

        Array of Digests to combine

      Returns Digest

    • Compute SHA-256 digest of data (legacy alias for fromImage).

      Parameters

      • data: Uint8Array

      Returns Digest

      Use fromImage instead

    • Get the raw digest bytes as a copy.

      Returns Uint8Array

    • Get a reference to the raw digest bytes.

      Returns Uint8Array

    • Get hex string representation.

      Returns string

    • Get hex string representation (alias for hex()).

      Returns string

    • Get base64 representation.

      Returns string

    • Get the first four bytes of the digest as a hexadecimal string. Useful for short descriptions.

      Returns string

    • Validate the digest against the given image.

      The image is hashed with SHA-256 and compared to this digest.

      Parameters

      • image: Uint8Array

      Returns boolean

      true if the digest matches the image.

    • Compare with another Digest.

      Parameters

      Returns boolean

    • Compare digests lexicographically.

      Parameters

      Returns number

    • Get string representation.

      Returns string

    • A Digest is its own digest provider - returns itself.

      Returns Digest

    • Returns the CBOR tags associated with Digest.

      Returns Tag[]

    • Returns the untagged CBOR encoding (as a byte string).

      Returns Cbor

    • Returns the tagged CBOR encoding.

      Returns Cbor

    • Returns the tagged value in CBOR binary representation.

      Returns Uint8Array

    • Creates a Digest by decoding it from untagged CBOR.

      Parameters

      • cbor: Cbor

      Returns Digest

    • Creates a Digest by decoding it from tagged CBOR.

      Parameters

      • cbor: Cbor

      Returns Digest

    • Static method to decode from tagged CBOR.

      Parameters

      • cbor: Cbor

      Returns Digest

    • Static method to decode from tagged CBOR binary data.

      Parameters

      • data: Uint8Array

      Returns Digest

    • Static method to decode from untagged CBOR binary data.

      Parameters

      • data: Uint8Array

      Returns Digest

    • Returns the UR representation of the Digest. Note: URs use untagged CBOR since the type is conveyed by the UR type itself.

      Returns UR

    • Returns the UR string representation.

      Returns string

    • Creates a Digest from a UR.

      Parameters

      • ur: UR

      Returns Digest

    • Creates a Digest from a UR string.

      Parameters

      • urString: string

      Returns Digest

    • Validate the given data against the digest, if any.

      Returns true if the digest is undefined or if the digest matches the image's digest. Returns false if the digest does not match.

      Parameters

      • image: Uint8Array
      • digest: Digest | undefined

      Returns boolean