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 = ".")
Character string providing full path to the gzip-compressed tarball holding the shipment payload, including encrypted files
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
Character string providing the full path to where the
decrypted file is to be written. Defaults to the current directory
Invisibly a character string providing the file path of the decrypted file.
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.
# Make temporary workspace wd <- tempdir() # Make a private-public key pair named "id_rsa" and "id_rsa.pub" sship_keygen(directory = wd) #> sship: Key pair written to /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmphfOHqM # 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) #> sship: Content encrypted and ready for shipment: /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T//RtmphfOHqM/secret.rds__20211126_095911.tar.gz # Decrypt secured file using the private key secret_file <- dec(tarfile = secure_secret_file, keyfile = file.path(wd, "id_rsa"), target_dir = wd) #> sship: Decrypted file written to /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/RtmphfOHqM/secret.rds