Serialize an object and calculate the checksum via
tools::md5sum()
. If tools::md5sum()
does not have the argument bytes
,
the object will be first serialized to a temporary file, which will be
deleted after the checksum is calculated, otherwise the raw bytes of the
object will be passed to the bytes
argument directly (which will be
faster than writing to a temporary file).
md5(...)
A character vector of the checksums of objects passed to md5()
. If
the arguments are named, the results will also be named.
x1 = 1
x2 = 1:10
x3 = seq(1, 10)
x4 = iris
x5 = paste
(m = xfun::md5(x1, x2, x3, x4, x5))
#> [1] "f17801eb638793fa56d7fbaad2ae9c6b" "80e76ade6af799c5b55e6447e7bf0d7b"
#> [3] "80e76ade6af799c5b55e6447e7bf0d7b" "999d7a900799faebc7d3eedbdf663570"
#> [5] "e146801e93d742df390caa1a551e1965"
stopifnot(m[2] == m[3]) # x2 and x3 should be identical
xfun::md5(x1 = x1, x2 = x2) # named arguments
#> x1 x2
#> "f17801eb638793fa56d7fbaad2ae9c6b" "80e76ade6af799c5b55e6447e7bf0d7b"