Skip to contents

Same contract as digest::digest(): by default the object is serialize()d (version 2, the 14-byte header skipped so the hash does not depend on the R version), serialize = FALSE hashes a character string or raw vector as-is, file = TRUE hashes a file's bytes, length and skip window the input, raw = TRUE returns the digest bytes, and seed feeds xxhash32 / xxhash64 / murmur32.

Usage

morie_digest(
  object,
  algo = c("md5", "sha1", "crc32", "sha256", "sha512", "xxhash32", "xxhash64",
    "murmur32", "crc32c", "sha224", "sha384"),
  serialize = TRUE,
  file = FALSE,
  length = Inf,
  skip = "auto",
  ascii = FALSE,
  raw = FALSE,
  seed = 0,
  errormode = c("stop", "warn", "silent"),
  serializeVersion = getOption("serializeVersion", 2L)
)

Arguments

object

the object, string, raw vector, or (with file) path.

algo

one of md5, sha1, crc32, sha256, sha512, xxhash32, xxhash64, murmur32, crc32c, sha224, sha384.

serialize, file, length, skip, ascii, raw, seed, errormode, serializeVersion

as in digest.

Value

the hex digest (character), or a raw vector when raw = TRUE.

Examples

morie_digest("abc", algo = "sha256", serialize = FALSE)
#> [1] "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
morie_digest(1:10)
#> [1] "c08951d2c283a799ab013bf845ed822e"
morie_digest(mtcars, algo = "xxhash64")
#> [1] "f4b89e63bc92af79"