You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi:
I am starting to look at this package, and while experimenting with decrypt_file(), it´s behavior when you give a wrong password in the dialog striked me.
The error you get leaves a zero length decrypted file created anyways, and also, I couldn´t inmediately delete it as it was still "in use" by my R session.
I wonder if some improvement could be done to this function by just catching the error and cleaning what openSSL does.
For instance:
decrypt_file<- function (.path, file_name = NULL, private_key_path = "id_rsa") {
if (!file.exists(.path)) {
stop("Encrypted file cannot be found.")
}
if (!file.exists(private_key_path)) {
stop("Private key cannot be found. \n Should be created with encryptr::genkeys")
}
if (!grepl(".encryptr.bin$", .path)) {
stop("Encrypted file has incorrect name. \n Should be created with encryptr::encrypt_file and end with '.encryptr.bin'")
}
if (is.null(file_name)) {
.file = gsub(".encryptr.bin", "", .path)
}
else {
.file = file_name
}
if (file.exists(.file)) {
stop("Unencrtyped file with same name exists at this location. \n Move or choose new name (file_name) to avoid it being overwritten.")
}
.crypt = readRDS(.path)
zz = file(.file, "wb") tryCatch(
error= function(cnd){
close(zz)
file.remove(.file)
stop(cnd)
},
openssl::decrypt_envelope(.crypt$data, .crypt$iv, .crypt$session,
key = private_key_path, password = openssl::askpass()) %>%
writeBin(zz) )
close(zz)
if (file.exists(.file)) {
cat("Decrypted file written with name '", .file,
"'\n", sep = "")
}
}
Regards
The text was updated successfully, but these errors were encountered:
Hi:
I am starting to look at this package, and while experimenting with decrypt_file(), it´s behavior when you give a wrong password in the dialog striked me.
The error you get leaves a zero length decrypted file created anyways, and also, I couldn´t inmediately delete it as it was still "in use" by my R session.
I wonder if some improvement could be done to this function by just catching the error and cleaning what openSSL does.
For instance:
Regards
The text was updated successfully, but these errors were encountered: