is_digest (v2)

lean-ctx · auth, sha256-validation, digest-check, hash-verification, dev-tools

Checks if a string is a valid SHA-256 digest prefixed with 'sha256:' and containing 64 hex characters.

// Source: https://github.com/yvgude/lean-ctx | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
pub(crate) fn is_digest(value: &str) -> bool {
    value
        .strip_prefix("sha256:")
        .is_some_and(|hex| is_hex(hex, 64))
}

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key