Add secret_encrypt_file() and secret_decrypt_file()#289
Conversation
| #' want to pass the unencrypted file to another function. | ||
| #' @rdname secrets | ||
| secret_decrypt_file <- function(path, key, envir = parent.frame()) { | ||
| val <- readChar(path, file.info(path)$size) |
There was a problem hiding this comment.
Is there a particular reason for focusing on text files? I think httr2's focus on encrypting/decrypting strings and text is part of how I ended up writing gargle::secret_(write|read)_rds() and gmailr::gm_token_(write|read).
There was a problem hiding this comment.
This is just because secret_encrypt() returns a base64 encoded string. This isn't really necessary for files, but it seems simple enough to keep it. It shouldn't affect your ability to encrypt and decrypt binary files. (And there's already secret_write_rds() and secret_read_rds() if you want rds files).
There was a problem hiding this comment.
Oh but I still need to read a binary file when encrypting. So probably better to be consistent.
There was a problem hiding this comment.
And that made me realise that there's a bunch of duplicate code between string and rds encryption, so overall a nice refactoring. Thanks for spotting the problem!
Co-authored-by: Jennifer (Jenny) Bryan <jenny.f.bryan@gmail.com>
#Conflicts: # NEWS.md
Fixes #237