Skip to contents

Add information about argument rewriting so that they can be used with encrypt and decrypt.


rewrite_register(package, name, arg, fn = NULL)



The name of the package with the function to support (as a scalar character). If your function has no package (e.g., a function you are working on outside of a package, use "" as the name).


The name of the function to support.


The name of the argument in the target function that refers to the file that should be encrypted or decrypted. This is the value you would pass through to file_arg in encrypt.


Optional (and should be rare) argument used to work around functions that pass all their arguments through to a second function as dots. This is how read.csv works. If needed this function is a length-2 character vector in the form "package", "name" with the actual function that is used. But this should be very rare!


If your package uses cyphr, it might be useful to add this as an .onLoad() hook.


# The saveRDS function is already supported.  But if we wanted to
# support it we could look at the arguments for the function:
#> function (object, file = "", ascii = FALSE, version = NULL, compress = TRUE, 
#>     refhook = NULL) 
# The 'file' argument is the one that refers to the filename, so
# we'd write:
cyphr::rewrite_register("base", "saveRDS", "file")
# It's non-API but you can see what is supported in the package by
# looking at
#>  [1] "base::load"          "base::readLines"     "base::readRDS"      
#>  [4] "base::save"          "base::saveRDS"       "base::writeLines"   
#>  [7] "readxl::read_excel"  "readxl::read_xls"    "readxl::read_xlsx"  
#> [10] "utils::read.csv"     "utils::read.csv2"    "utils::read.delim"  
#> [13] "utils::read.delim2"  "utils::read.table"   "utils::write.csv"   
#> [16] "utils::write.csv2"   "utils::write.table"  "writexl::write_xlsx"