# SHA-256 hash as character string:
sha256("secret base")
# SHA-256 hash as raw vector:
sha256("secret base", convert = FALSE)
# SHA-256 hash a file:
file <- tempfile(); cat("secret base", file = file)
sha256(file = file)
unlink(file)
# SHA-256 HMAC using a character string secret key:
sha256("secret", key = "base")
# SHA-256 HMAC using a raw vector secret key:
sha256("secret", key = charToRaw("base"))
Run the code above in your browser using DataLab