首页 > 解决方案 > How to save the password in script R in package ‘encryptr’?

问题描述

I do that:

library(encryptr)
genkeys()

And I created the password: 0)]30l^8

password<-"0)]30l^8"
data(gp)
write.csv(gp, "gp.csv")
encrypt_file("gp.csv")

My problem is: How do I automatically enter the password on the decrypt_file("gp.csv.encryptr.bin", file_name = "gp2.csv")

I need this to decrypt many files in a short time.

标签: rencryptionpassword-encryption

解决方案


非常感谢这个问题。不建议在脚本中保存密码,因为在大多数情况下这会破坏加密文件的目的。尽管不建议这样做,但您可以解决此有意的功能。

password<-"0)]30l^8"
.crypt = readRDS("gp.csv.encryptr.bin") # in file
zz = file("gp2.csv", "wb") # out file
openssl::decrypt_envelope(.crypt$data, .crypt$iv, .crypt$session, key = "id_rsa", password = password) %>%
  writeBin(zz)
close(zz)

推荐阅读