verify_sha256: Verify a File's SHA256 Against an Expected Digest

View source: R/lib_data_loader.R

verify_sha256R Documentation

Verify a File's SHA256 Against an Expected Digest

Description

Computes the SHA256 digest of a file (via the digest package) and compares it to the expected value pinned in provenance.

Usage

verify_sha256(path, expected_sha)

Arguments

path

Path to the file to hash.

expected_sha

The expected SHA256 digest, as a lowercase hex string.

Value

A list with actual (computed digest), expected (the value passed in), and match (logical; TRUE if they are identical).

Examples

f <- tempfile()
writeLines("hello capsule", f)

# Matching digest -> match TRUE.
chk <- verify_sha256(f, sha256_file(f))
chk$match          # TRUE

# A wrong expected digest -> match FALSE, with both values reported.
bad <- verify_sha256(f, "0000000000000000000000000000000000000000000000000000000000000000")
bad$match          # FALSE
bad$actual         # the real digest

rmoriebricklayer documentation built on Aug. 5, 2026, 9:08 a.m.