sha3 | R Documentation |
Returns a SHA-3 hash of the supplied object or file.
sha3(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 one of 224, 256, 384 or 512. |
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. |
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.
The SHA-3 Secure Hash Standard was published by the National Institute of Standards and Technology (NIST) in 2015 at \Sexpr[results=rd]{tools:::Rd_expr_doi("doi:10.6028/NIST.FIPS.202")}.
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.
# SHA3-256 hash as character string:
sha3("secret base")
# SHA3-256 hash as raw vector:
sha3("secret base", convert = FALSE)
# SHA3-224 hash as character string:
sha3("secret base", bits = 224)
# SHA3-384 hash as character string:
sha3("secret base", bits = 384)
# SHA3-512 hash as character string:
sha3("secret base", bits = 512)
# SHA3-256 hash a file:
file <- tempfile(); cat("secret base", file = file)
sha3(file = file)
unlink(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.