Skip to content

How to use digests well

Use SHA-256 for security, compare in constant time, and pin by digest when identity matters.

Digests that hold

  1. Never compare with `==` in security code

    Use constant-time comparison (hash_equals in PHP, hmac.compare_digest in Python) to avoid timing side-channels.

  2. Pin by digest, not tag

    Container images, tarballs and packages should reference name@sha256:..., not name:latest.

  3. Prefer SHA-256

    MD5 and SHA-1 have known collision attacks. Never use them for security, signatures or integrity.

  4. Record the digest in the manifest

    Every artifact should carry its digest in the manifest so deploys can verify.