keccak | R Documentation |
Returns a Keccak hash of the supplied object or file.
keccak(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. Must be one of 224, 256, 384 or 512. |
convert |
logical |
file |
character file name / path. If specified, |
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.
Keccak is the underlying algorithm for SHA-3, and is identical apart from the value of the padding parameter.
The Keccak algorithm was designed by G. Bertoni, J. Daemen, M. Peeters and G. Van Assche.
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.
# Keccak-256 hash as character string:
keccak("secret base")
# Keccak-256 hash as raw vector:
keccak("secret base", convert = FALSE)
# Keccak-224 hash as character string:
keccak("secret base", bits = 224)
# Keccak-384 hash as character string:
keccak("secret base", bits = 384)
# Keccak-512 hash as character string:
keccak("secret base", bits = 512)
# Keccak-256 hash a file:
file <- tempfile(); cat("secret base", file = file)
keccak(file = file)
unlink(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.