Description Usage Arguments Value Author(s) References See Also Examples
The hmac
function calculates a message authentication code
(MAC) involving the specified cryptographic hash function in
combination with a given secret key.
1 2 3 |
key |
An arbitrary character or numeric vector, to use as pre-shared secret key. |
object |
An arbitrary R object which will then be passed to the
|
algo |
The algorithms to be used; currently available choices are
|
serialize |
default value of |
raw |
This flag alters the type of the output. Setting this to
|
... |
All remaining arguments are passed to |
The hmac
function uses the digest
to return a hash
digest as specified in the RFC 2104.
Mario Frasca mfrasca@zonnet.nl.
MD5: http://www.ietf.org/rfc/rfc1321.txt.
SHA-1: http://www.itl.nist.gov/fipspubs/fip180-1.htm. SHA-256: http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf. CRC32: ftp://ftp.rocksoft.com/cliens/rocksoft/papers/crc_v3.txt.
http://www.aarongifford.com/computers/sha.html for the integrated C implementation of sha-512.
http://www.cr0.net:8040/code/crypto for the underlying C functions used here for sha-1 and md5, and further references.
http://zlib.net for documentation on the zlib library which supplied the code for crc32.
http://en.wikipedia.org/wiki/SHA_hash_functions for documentation on the sha functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Standard RFC 2104 test vectors
current <- hmac('Jefe', 'what do ya want for nothing?', "md5")
target <- '750c783e6ab0b503eaa86e310a5db738'
stopifnot(identical(target, as.character(current)))
current <- hmac(rep(0x0b, 16), 'Hi There', "md5")
target <- '9294727a3638bb1c13f48ef8158bfc9d'
stopifnot(identical(target, as.character(current)))
current <- hmac(rep(0xaa, 16), rep(0xdd, 50), "md5")
target <- '56be34521d144c88dbb8c733f0e8b3f6'
stopifnot(identical(target, as.character(current)))
## SHA1 tests inspired to the RFC 2104 and checked against the python
## hmac implementation.
current <- hmac('Jefe', 'what do ya want for nothing?', "sha1")
target <- 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79'
stopifnot(identical(target, as.character(current)))
current <- hmac(rep(0x0b, 16), 'Hi There', "sha1")
target <- '675b0b3a1b4ddf4e124872da6c2f632bfed957e9'
stopifnot(identical(target, as.character(current)))
current <- hmac(rep(0xaa, 16), rep(0xdd, 50), "sha1")
target <- 'd730594d167e35d5956fd8003d0db3d3f46dc7bb'
stopifnot(identical(target, as.character(current)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.