Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypt serialized R object #5

Closed
jmueller17 opened this issue Oct 3, 2018 · 2 comments
Closed

Decrypt serialized R object #5

jmueller17 opened this issue Oct 3, 2018 · 2 comments

Comments

@jmueller17
Copy link

I posted this issue on stackoverflow, but with little success. Since this is related to gpg library, maybe Jeroen can help? I encrypt a serialized data frame.

df <- data.frame(A=c(1,2,3), B=c("A", "B", "C"), C=c(T,F,F)) 
df <- serialize(df, con=NULL, ascii=T) 
enc <- gpg_encrypt(df, receiver="your_key_here") 
writeBin(enc, "test.df.gpg")

But I can't decrypt it, or rather I can decrypt but gpg_decrypt() delivers a sequence of plain characters from which it is impossible to restore the original data frame.

dec <- gpg_decrypt("test.df.gpg") 
df <- unserialize(dec) #throws error ! 

The encrypted file is ok. I can decrypt manually on the command line and then restore the original R dataframe with readRDS(). But not via the gpg_decrypt() function? Any thoughts?

@jeroen
Copy link
Owner

jeroen commented Dec 29, 2018

It looks like I was assuming text data before. I have added an argument as_text to gpg_decrypt() so you should be able to do:

gpg_decrypt("test.df.gpg", as_text = FALSE)

and then get raw output.

@jmueller17
Copy link
Author

Thank you! Now it works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants