DigestAlgorithm

Backed enum for the supported message-digest algorithms.

Namespace: Com\Tecnick\Pdf\Sign

enum DigestAlgorithm: string

Source: src/DigestAlgorithm.php:36

Backed enum for the supported message-digest algorithms. It is the single closed set for both the CMS builder and the RFC 3161 message imprint. The backing value is the lowercase algorithm name accepted by both.

Cases

  • Sha256 = 'sha256'
  • Sha384 = 'sha384'
  • Sha512 = 'sha512'

Methods

digestLength()

Length in bytes of a raw digest produced by this algorithm.

public digestLength(): int

Returns: int

Source: src/DigestAlgorithm.php:93

fromLoose()

Resolve a loose digest algorithm value to the matching enum case.

Accepts the canonical algorithm string (as validated by Config and Timestamp\Config) or an enum instance (returned unchanged). Unknown values throw, matching the closed set enforced by both configs.

public static fromLoose(string|self $value): self

Parameters:

  • $value (string|self): Digest algorithm name or enum case.

Returns: self

Throws:

  • Exception: if the value does not match a known digest algorithm.

Source: src/DigestAlgorithm.php:55

oid()

OID of this algorithm’s AlgorithmIdentifier (NIST, RFC 5754 section 2).

Read by the CMS builder, the CMS reader, and the RFC 3161 request.

public oid(): string

Returns: string

Source: src/DigestAlgorithm.php:107

tryFromOid()

Resolve a digest AlgorithmIdentifier OID to the matching enum case.

public static tryFromOid(string $oid): self|null

Parameters:

  • $oid (string)

Returns: self|null: Null when the OID names no supported algorithm.

Source: src/DigestAlgorithm.php:79

values()

The backing value of every case, in declaration order.

public static values(): list<string>

Returns: list<string>

Source: src/DigestAlgorithm.php:69