sha256: Get the SHA256 checksum of a file.

View source: R/getData.R

sha256R Documentation

Get the SHA256 checksum of a file.

Description

Wrapper around openssl::sha256() to make it easy to calculate a checksum of a file. Converts the returned hash code to a string by default, but can set as.hash= TRUE to get the unconverted raw byte based hash object instead.

Usage

sha256(file, as.hash = FALSE)

Arguments

file

The path to a file to checksum

as.hash

Set TRUE to return the hash byte object instead of converting to a string

Value

Returns the hash as a string, unless as.hash= TRUE is set, in which case the hash byte object as obtained from openssl::sha256() is returned.

Examples

aFile <- JefferysRUtils::makeTempFile( c( "one fish", "two fish" ))
aHash <- sha256( aFile )
aHash
#> "a5fb5357754cb5a6ae85090aed325435388c8b0d6e295a058bab55102ffa188e"

aHashObj <- sha256( aFile, as.hash= TRUE )
class(aHashObj)
#> [1] "hash"   "sha256"
str(aHashObj)
#> 'hash' raw [1:32] a5 fb 53 57 ...


jefferys/JefferysRUtils documentation built on Jan. 12, 2024, 9:18 p.m.