Play with the cyphr package

March 24, 2019
By

(This article was first published on Shige's Research Blog, and kindly contributed to R-bloggers)

The cyphr package seems to provide a good choice for small research group that shares sensitive data over internet (e.g., DropBox). I did some simple experiment myself and made sure it can actually serve my purpose.

I did my experiment on two computers (using openssl): I created the test data on my Linux workstation running Manjaro then I tried to access the data on a Windows 7 laptop.

For creating the data (Linux workstation):

library(cyphr)

# Create the test data

data_dir <- file.path(“~/Dropbox/temp_files”, “data”)
dir.create(data_dir)
dir(data_dir)

# Encrypt the test data

cyphr::data_admin_init(data_dir)

key <- cyphr::data_key(data_dir)


filename <- file.path(data_dir, “iris.rds”)

cyphr::encrypt(saveRDS(iris, filename), key)
dir(data_dir)

# Cannot read the data with decrypting it

readRDS(filename)

# Read the decrypted version of the data

head(cyphr::decrypt(readRDS(filename), key))

For accessing the data (Windows laptop):

library(cyphr)

key <- data_key(“C:/Users/Ssong/Dropbox/temp_files/data”, path_user = “C:/Users/Ssong/.ssh”)


# Make data access request

data_request_access(“C:/Users/Ssong/Dropbox/temp_files/data”, 
path_user = “C:/Users/Ssong/.ssh”)

On Windows 7,  the system cannot locate the public located in “~/.ssh”, which is pretty dumb.

Going back to the Linux workstation to approve the data access request:

# Review the request and approve (to share with other users)
req <- data_admin_list_requests(data_dir)
data_admin_authorise(data_dir, yes = TRUE)
data_admin_list_keys(data_dir)

Now I can access the data on my Windows laptop:

key <- data_key(“C:/Users/Ssong/Dropbox/temp_files/data”, path_user = “C:/Users/Ssong/.ssh”)

d <- decrypt( readRDS( “C:/Users/Ssong/Dropbox/temp_files/data/iris.rds”), key)


To leave a comment for the author, please follow the link and comment on their blog: Shige's Research Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)