sha256_file: Compute a File's SHA256 Digest

View source: R/lib_helpers.R

sha256_fileR Documentation

Compute a File's SHA256 Digest

Description

Returns the SHA256 digest of a file as a lowercase hex string, using the digest package. Used to record and verify data provenance.

Usage

sha256_file(path)

Arguments

path

Path to the file to hash.

Value

The SHA256 digest as a character string.

Examples

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

# Deterministic: the same bytes always yield the same digest.
identical(sha256_file(f), sha256_file(f))

# Any change to the file changes the digest (tamper-evidence).
before <- sha256_file(f)
writeLines("hello capsule (edited)", f)
after <- sha256_file(f)
before == after      # FALSE

# Provenance pin: record a digest, verify it later.
pinned <- sha256_file(f)
stopifnot(sha256_file(f) == pinned)

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