save_and_lock() saves a data frame or R object to a file and then locks
it using RSA encryption.
Usage
save_and_lock(
x,
file,
type = "rds",
public_key = here::here(".ssh", "id_rsa.pub"),
...
)Arguments
- x
An R object to be saved and locked. If
type = "csv",xmust be adata.frame.- file
A
characterstring indicating the file path to save the object to.- type
A
characterstring indicating the file type to save the object as. Must be one of"csv"or"rds"(default:"rds").- public_key
(optional) An
opensslRSA public key or acharacterstring specifying the public key path. Seersa_keygen()to learn how to create an RSA key pair (default:here::here(".ssh", "id_rsa.pub")).- ...
(optional) Additional arguments passed to
write_csvorwrite_rds.
Value
An invisible string containing the locked file path.
See also
Other lock/unlock functions:
lock_dir(),
lock_file()
Examples
## Creating Keys and Test Object -----
temp_dir <- tempfile("dir")
dir.create(temp_dir)
rsa_keygen(temp_dir)
#> ℹ Keys successfully created at /tmp/RtmpwNDBbf/dir1c0d3bb44fae.
x <- letters
## Locking and Saving Objects -----
x |>
save_and_lock(
file = tempfile(),
type = "rds",
public_key = file.path(temp_dir, "id_rsa.pub")
)
#> ℹ Locked file written at /tmp/RtmpwNDBbf/file1c0dd76ed14.lockr.
#> [1] "/tmp/RtmpwNDBbf/file1c0dd76ed14.lockr"