dec {sship} | R Documentation |
This function tries to reverse the process of enc and hence depend on the conventions used there.
dec(tarfile, keyfile = "~/.ssh/id_rsa", target_dir = ".")
tarfile |
Character string providing full path to the gzip-compressed tarball holding the shipment payload, including encrypted files. |
keyfile |
Character string providing the full path to the private RSA
key to be used for decryption of the encrypted key that is part of the
shipment. Default value is set to |
target_dir |
Character string providing the full path to where the
decrypted file is to be written. Defaults to the current directory
|
Some of the functions used here might be vulnerable to differences between systems running R. Possible caveats may be the availability of the (un)tar-function and how binary streams/files are treated.
Invisibly a character string providing the file path of the decrypted file.
# Please note that these examples will write files to a local temporary
# directory.
## Make temporary workspace
wd <- tempdir()
## Make a private-public key pair named "id_rsa" and "id_rsa.pub"
keygen(directory = wd, type = "rsa", overwrite_existing = TRUE)
## Make a secured (encrypted) file
saveRDS(iris, file = file.path(wd, "secret.rds"), ascii = TRUE)
pubkey <- readLines(file.path(wd, "id_rsa.pub"))
secure_secret_file <-
enc(filename = file.path(wd, "secret.rds"),
pubkey_holder = NULL,
pubkey = pubkey)
## Decrypt secured file using the private key
secret_file <-
dec(tarfile = secure_secret_file,
keyfile = file.path(wd, "id_rsa"),
target_dir = wd)