digest 0.5.0

[This article was first published on Thinking inside the box , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A new version of the digest package (which generates hash function summaries for arbitrary (and possibly nested) R objects using any of the standard md5, sha-1, sha-256 or crc32 algorithms) is now on CRAN.

Thanks to a patch by Mario Frasca, digest now contains a second (exported) function hmac() to generate Hash-based Message Authentication Code as defined in RFC 2104. Reference output from RFC 2104 is used to validate this functionality as shown below where we run the example code from the hmac() help page:

R> library(digest)
R> example(hmac)

hmacR> ## Standard RFC 2104 test vectors
hmacR> current <- hmac('Jefe', 'what do ya want for nothing?', "md5")

hmacR> target <- '750c783e6ab0b503eaa86e310a5db738'

hmacR> stopifnot(identical(target, as.character(current)))

hmacR> current <- hmac(rep(0x0b, 16), 'Hi There', "md5")

hmacR> target <- '9294727a3638bb1c13f48ef8158bfc9d'

hmacR> stopifnot(identical(target, as.character(current)))

hmacR> current <- hmac(rep(0xaa, 16), rep(0xdd, 50), "md5")

hmacR> target <- '56be34521d144c88dbb8c733f0e8b3f6'

hmacR> stopifnot(identical(target, as.character(current)))

hmacR> ## SHA1 tests inspired to the RFC 2104 and checked against the python
hmacR> ## hmac implementation.
hmacR> current <- hmac('Jefe', 'what do ya want for nothing?', "sha1")

hmacR> target <- 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79'

hmacR> stopifnot(identical(target, as.character(current)))

hmacR> current <- hmac(rep(0x0b, 16), 'Hi There', "sha1")

hmacR> target <- '675b0b3a1b4ddf4e124872da6c2f632bfed957e9'

hmacR> stopifnot(identical(target, as.character(current)))

hmacR> current <- hmac(rep(0xaa, 16), rep(0xdd, 50), "sha1")

hmacR> target <- 'd730594d167e35d5956fd8003d0db3d3f46dc7bb'

hmacR> stopifnot(identical(target, as.character(current)))
R> 

Also, CRANberries shows the difference to the previsious release 0.4.2 as follows:

Diff between digest versions 0.4.2 dated 2009-12-06 and 0.5.0 dated 2011-05-30

 digest-0.4.2/digest/INDEX                      |only
 digest-0.4.2/digest/R/zzz.R                    |only
 digest-0.4.2/digest/inst                       |only
 digest-0.5.0/digest/ChangeLog                  |only
 digest-0.5.0/digest/DESCRIPTION                |   33 ++++++++++++-------------
 digest-0.5.0/digest/NAMESPACE                  |    7 +++--
 digest-0.5.0/digest/R/hmac.R                   |only
 digest-0.5.0/digest/man/hmac.Rd                |only
 digest-0.5.0/digest/tests/digestTest.Rout.save |    2 -
 digest-0.5.0/digest/tests/hmacTest.R           |only
 digest-0.5.0/digest/tests/hmacTest.Rout.save   |only
 11 files changed, 22 insertions(+), 20 deletions(-)

With that, special thanks to Mario Frasca for the patch and to Henrik Bengtsson for helpful discussion. We took some care to ensure that the existing interface to the digest() function remains unaffected.

To leave a comment for the author, please follow the link and comment on their blog: Thinking inside the box .

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)