Skip to content

Calculate the MD5 hash of each element of a character vector.

Usage

hash_md5(x)

hash_raw_md5(x)

hash_obj_md5(x, serialize_version = 2)

hash_file_md5(paths)

Arguments

x

Character vector. If not a character vector, then as.character() is used to try to coerce it into one. NA entries will have an NA hash.

serialize_version

Workspace format version to use, see base::serialize().

paths

Character vector of file names.

Value

hash_md5() returns a character vector of hexadecimal MD5 hashes.

hash_raw_md5() returns a character scalar.

hash_obj_md5() returns a character scalar.

Details

hash_raw_md5() calculates the MD5 hash of the bytes of a raw vector.

hash_obj_md5() calculates the MD5 hash of an R object. The object is serialized into a binary vector first.

hash_file_md5() calculates the MD5 hash of one or more files.

See also

tools::md5sum() for a base R MD5 function that works on files.

Other hash functions: hash_animal(), hash_emoji(), hash_sha1(), hash_sha256(), hash_xxhash()

Examples

hash_md5(c("foo", NA, "bar", ""))
#> [1] "acbd18db4cc2f85cedef654fccc4a4d8" NA                                
#> [3] "37b51d194a7513e45b56f6524f2d51f2" "d41d8cd98f00b204e9800998ecf8427e"