Is there a way to encrypt SPSS-files (.sav) using the cyphr-package? Encrypting .csv works fine, but when I try to encrypt .sav, I get following error-message:
Error in db_lookup(dat$ns, dat$name, file_arg) :
Rewrite rule for haven::write_sav not found
I have found a solution where I first convert the original files (*.csv and .sav) into *.rds files. After that they are encrypted. This works as intended.
With this procedure, encrypted *.rds files with the same name are created and saved in a separate folder for all *.csv and *.sav in the original folder.
Load packages:
Set paths to the folder with original unencrypted data (
data_originals) and to the folder to store the encrypted data (data_encypted):Set working directory:
Specify the directory in which the encrypted files are to be stored (
data_encypted).Set path of personal key:
Create a key for the data and encrypt that key with personal key:
Get the data key and add encrypted data to the directory:
For *.csv-files:
Write all *.csv files in the folder
data_originalsto a list:Read in *.csv files located in the folder
data_originals:Create a list of what the *.csv files should be named as *.rds files:
Save the *.csv files as *.rds files to the folder created for the encrypted files (
data_encrypted):For *.sav-files:
Set working directory:
Write all *.sav files in the folder
data_originalsto a list:Read in *.sav files located in the folder
data_originals:Create a list of what the *.sav files should be named as *.rds files:
Save the *.sav files as *.rds files to the folder created for the encrypted files (
data_encrypted):Write the names of the *.rds files that are now in the
data_encryptedfolder and are still to be encrypted in a list:Read in all *.rds files located in the folder
data_encrypted.Define paths:
Encrypt and save all files in folder
data_encrypted: