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 native R serialization. |
bits |
integer output size of the returned hash. Value must be between 8 and 2^24. |
convert |
logical |
file |
character file name / path. If specified, |
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 representation and the headers (containing R version and native encoding information) are skipped to ensure portability across platforms.
As hashing is performed in a streaming fashion, there is no materialization of, or memory allocation for, the serialized object.
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.