EVOLUTION-MANAGER
Edit File: vdigest.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Set a vectorised function for creating hash function digests</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for getVDigest {digest}"><tr><td>getVDigest {digest}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Set a vectorised function for creating hash function digests</h2> <h3>Description</h3> <p>The <code>getVDigest</code> function extends <code>digest</code> by allowing one to set a function that returns hash summaries as a character vector of the same length as the input. It also provides a performance advantage when repeated calls are necessary (e.g. applying a hash function repeatedly to an object). The returned function contains the same arguments as <code>digest</code> with the exception of the <code>raw</code> argument (see <code><a href="digest.html">digest</a></code> for more details). </p> <h3>Usage</h3> <pre> getVDigest(algo=c("md5", "sha1", "crc32", "sha256", "sha512", "xxhash32", "xxhash64", "murmur32", "spookyhash"), errormode=c("stop","warn","silent")) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>algo</code></td> <td> <p>The algorithms to be used; currently available choices are <code>md5</code>, which is also the default, <code>sha1</code>, <code>crc32</code>, <code>sha256</code>, <code>sha512</code>, <code>xxhash32</code>, <code>xxhash64</code>, <code>murmur32</code> and <code>spookyhash</code>.</p> </td></tr> <tr valign="top"><td><code>errormode</code></td> <td> <p>A character value denoting a choice for the behaviour in the case of error: ‘stop’ aborts (and is the default value), ‘warn’ emits a warning and returns <code>NULL</code> and ‘silent’ suppresses the error and returns an empty string.</p> </td></tr> </table> <h3>Details</h3> <p>Note that since one hash summary will be returned for each element passed as input, care must be taken when determining whether or not to include the data structure as part of the object. For instance, to return the equivalent output of <code>digest(list("a"))</code> it would be necessary to wrap the list object itself <code>getVDigest()(list(list("a")))</code> </p> <h3>Value</h3> <p>The <code>getVDigest</code> function returns a function for a given algorithm and error-mode. </p> <h3>See Also</h3> <p><code><a href="digest.html">digest</a></code>, <code><a href="../../base/html/serialize.html">serialize</a></code>, <code><a href="../../tools/html/md5sum.html">md5sum</a></code></p> <h3>Examples</h3> <pre> stretch_key <- function(d, n) { md5 <- getVDigest() for (i in seq_len(n)) d <- md5(d, serialize = FALSE) d } stretch_key('abc123', 65e3) sha1 <- getVDigest(algo = 'sha1') sha1(letters) md5Input <- c("", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", paste("12345678901234567890123456789012345678901234567890123456789012", "345678901234567890", sep="")) md5Output <- c("d41d8cd98f00b204e9800998ecf8427e", "0cc175b9c0f1b6a831c399e269772661", "900150983cd24fb0d6963f7d28e17f72", "f96b697d7cb7938d525a2f31aaf161d0", "c3fcd3d76192e4007dfb496cca67e13b", "d174ab98d277d9f5a5611c2c9f419d9f", "57edf4a22be3c955ac49da2e2107b67a") md5 <- getVDigest() stopifnot(identical(md5(md5Input, serialize = FALSE), md5Output)) stopifnot(identical(digest(list("abc")), md5(list(list("abc"))))) sha512Input <-c( "", "The quick brown fox jumps over the lazy dog." ) sha512Output <- c( paste0("cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce", "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"), paste0("91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bb", "c6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed") ) sha512 <- getVDigest(algo = 'sha512') stopifnot(identical(sha512(sha512Input, serialize = FALSE), sha512Output)) </pre> <hr /><div style="text-align: center;">[Package <em>digest</em> version 0.6.25 <a href="00Index.html">Index</a>]</div> </body></html>