Skip to content

Helpers for encrypting/decrypting files #237

@hadley

Description

@hadley

Since sometimes you need to pass a path to some other function:

secret_read_file <- function(path, envir = parent.frame()) {
  val <- readChar(path, file.info(path)$size)  
  enc <- secret_encrypt(val, key = "GARGLE_KEY")
  
  path <- withr::with_tempfile(envir = envir)
  writeChar(enc, path)
  Sys.chmod(path, 400)
  path
}

secret_write_file <- function(path_in, path_out, envir = parent.frame()) {
  val <- readChar(path_in, file.info(path_in)$size)  
  enc <- secret_decrypt(val, key = "GARGLE_KEY")
  
  writeChar(enc, path_out)
  invisible(path_out)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions