shake256 | R Documentation |
Returns a SHAKE256 hash of the supplied object or file.
shake256(x, bits = 256L, convert = TRUE, file)
x |
object to hash. A character string or raw vector (without attributes) is hashed ‘as is’. All other objects are stream hashed using R serialization (but without allocation of the serialized object). |
bits |
[default 256L] output size of the returned hash. Must be between 8 and 2^24 and coercible to integer. |
convert |
[default TRUE] if TRUE, the hash is converted to its hex representation as a character string, if FALSE, output directly as a raw vector, or if NA, a vector of (32-bit) integer values. |
file |
character file name / path. If specified, ‘x’ is ignored. The file is stream hashed, thus capable of handling files larger than memory. |
To produce single integer values suitable for use as random seeds for R's pseudo random number generators (RNGs), set ‘bits’ to 32 and ‘convert’ to NA.
A character string, raw or integer vector depending on ‘convert’.
Where this is used, serialization is always version 3 big-endian represenation and the headers (containing R version and native encoding information) are skipped to ensure portability across platforms.
This implementation is based on one by 'The Mbed TLS Contributors' under the 'Mbed TLS' Trusted Firmware Project at https://www.trustedfirmware.org/projects/mbed-tls.
# SHAKE256 hash as character string:
shake256("secret base")
# SHAKE256 hash as raw vector:
shake256("secret base", convert = FALSE)
# SHAKE256 hash to integer:
shake256("secret base", bits = 32L, convert = NA)
# SHAKE256 hash a file:
file <- tempfile(); cat("secret base", file = file)
shake256(file = file)
unlink(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.