md5 {md5}R Documentation

Compute MD5 hash of a vector.

Description

md5 computes MD5 hash of a vector. Currently the only supported vectors are integer, real and raw.

Usage

md5(x, raw = FALSE)

Arguments

x

vector

raw

if set to FALSE then a string (hex) representation of the hash is returned, raw vector of 16 bytes otherwise

Details

The hash is computed on the binary representation of the vector, so the hash of numeric vectors will differ on machines with a different endianness (use serialize if that is an issue).

Value

If raw is FALSE then a character vector of length one with the one element having 32 characters representing the hash in hexadecimal notation. Otherwise a raw vector of length 16 representing the hash.

Note

This function is deliberately very simple, does not perform hashing of recursive objects and ignores attributes. This is due to the original intended use - it is always possible to use serialize for hashing of complex obejcts.

Examples

## classic examples from the literature to verify correctness:
## should be 9e107d9d372bb6826bd81d3542a419d6
md5(charToRaw("The quick brown fox jumps over the lazy dog"))

## empty vector should be d41d8cd98f00b204e9800998ecf8427e
md5(integer(0))

## other, random examples
md5(1:10)
md5(1:10, TRUE)

[Package md5 version 1.0-0 Index]