6

I'm trying to protect some datafiles I save in R. Is there a way to password protect an R datafile (.Rdata) ?

Thank you

rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
Tracy
  • 699
  • 2
  • 9
  • 21
  • 3
    I suggest to place/mount it on a volume that is encrypted and most operating systems will prompt you for a passsword. There once was a thread on `comp.lang.r.general`you find the short thread here [Sourcing encrypted files](http://thread.gmane.org/gmane.comp.lang.r.general/94290/) – Dilettant Jun 17 '16 at 20:50
  • 1
    I haven't used this, but it looks promising: https://github.com/hadley/secure – Jason Oct 06 '16 at 12:33
  • An encrypted volume is better than nothing but still an evil admin who knows the volume encryption secret can decrypt the data file (e. g. from a backup tape). – R Yoda Oct 17 '18 at 12:25
  • 1
    To store the credentials there is now a good package at CRAN: `secret` https://cran.r-project.org/package=secret – R Yoda Oct 17 '18 at 12:25

1 Answers1

2

You can make a call to GnuPG for it to encrypt the file using public key cryptography after you create it in the same script. This would allow additionally for you to share the encrypted files with others without sharing your password.

More on GnuPG: https://www.gnupg.org/gph/en/manual.html

Though I would personally pipe shell commands to encrypt the file rather than using a third party tool/package, there is a gpg package on cran: https://cran.r-project.org/web/packages/gpg/index.html

maerg
  • 36
  • 1
  • 5