# Support both strings and binary
md5("foo")
md5(charToRaw("foo"))
# Compare to digest
library(digest)
digest("foo", "md5", serialize = FALSE)
# Other way around
digest(cars, skip = 0)
md5(serialize(cars, NULL))
# Vectorized for strings
md5(c("foo", "bar", "baz"))
# Stream-verify from connections (including files)
myfile <- system.file("CITATION")
md5(file(myfile))
check md5 from: http://cran.r-project.org/bin/windows/base/old/3.1.1/md5sum.txt
md5(url("http://cran.r-project.org/bin/windows/base/old/3.1.1/R-3.1.1-win.exe"))
# Use a salt to prevent dictionary attacks
sha1("admin") # googleable
sha1("admin", salt="some_random_salt_value") #not googleable
# Use a random salt to identify duplicates while anonymizing values
sha256("john") # googleable
sha256(c("john", "mary", "john"), salt = rand_bytes(100))
Run the code above in your browser using DataLab