R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("digest-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('digest') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "digest" > > ### * digest > > flush(stderr()); flush(stdout()) > > ### Name: digest > ### Title: Create hash function digests for arbitrary R objects > ### Aliases: digest > ### Keywords: misc > > ### ** Examples > > > ## Standard RFC 1321 test vectors > md5Input <- + c("", + "a", + "abc", + "message digest", + "abcdefghijklmnopqrstuvwxyz", + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + paste("12345678901234567890123456789012345678901234567890123456789012", + "345678901234567890", sep="")) > md5Output <- + c("d41d8cd98f00b204e9800998ecf8427e", + "0cc175b9c0f1b6a831c399e269772661", + "900150983cd24fb0d6963f7d28e17f72", + "f96b697d7cb7938d525a2f31aaf161d0", + "c3fcd3d76192e4007dfb496cca67e13b", + "d174ab98d277d9f5a5611c2c9f419d9f", + "57edf4a22be3c955ac49da2e2107b67a") > > for (i in seq(along=md5Input)) { + md5 <- digest(md5Input[i], serialize=FALSE) + stopifnot(identical(md5, md5Output[i])) + } > > sha1Input <- + c("abc", + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + NULL) > sha1Output <- + c("a9993e364706816aba3e25717850c26c9cd0d89d", + "84983e441c3bd26ebaae4aa1f95129e5e54670f1", + "34aa973cd4c4daa4f61eeb2bdbad27316534016f") > > for (i in seq(along=sha1Input)) { + sha1 <- digest(sha1Input[i], algo="sha1", serialize=FALSE) + stopifnot(identical(sha1, sha1Output[i])) + } > > crc32Input <- + c("abc", + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + NULL) > crc32Output <- + c("352441c2", + "171a3f5f", + "2ef80172") > > for (i in seq(along=crc32Input)) { + crc32 <- digest(crc32Input[i], algo="crc32", serialize=FALSE) + stopifnot(identical(crc32, crc32Output[i])) + } > > > # one of the FIPS- > sha1 <- digest("abc", algo="sha1", serialize=FALSE) > stopifnot(identical(sha1, "a9993e364706816aba3e25717850c26c9cd0d89d")) > > # example of a digest of a standard R list structure > digest(list(LETTERS, data.frame(a=letters[1:5], b=matrix(1:10,ncol=2)))) [1] "c0c49c678d373c1668ee6da9bf8d6845" > > > > ### *