Learn R Programming

EQUALencrypt (version 0.1.0)

EQUAL_perform_file_decryption: Wrapper function for file decryption

Description

"A wrapper function which takes the user input obtained via the Rshiny app, decrypts a file using the EQUAL_decrypt_file() function after verifying the digital signature on the encrypted file using the EQUAL_verify_signature() function."

Usage

EQUAL_perform_file_decryption(rv)

Value

"

html_message

message to the user which includes whether the decryption was successfully performed

"

decrypted_file_path

path to the decrypted file

Arguments

rv

A list supplied by EQUAL-STATS application based on user input

Author

Kurinchi Gurusamy

References

https://sites.google.com/view/equal-group/home

See Also

EQUAL_decrypt_file() EQUAL_verify_signature()

Examples

Run this code
library(openssl)
# Data ####
data <- lapply(1:3, function(x) {
  mean = sample(1:100, 1, replace = FALSE)
  sd = sample(1:100, 1, replace = FALSE)
  rnorm(100, mean = mean, sd = sd)
})
data <- do.call(cbind.data.frame, data)
colnames(data) <- paste0("v", formatC(1:3, width = 6, flag = "0"))
test_file <- write.csv(data, paste0(tempdir(), "/test.csv"), row.names = FALSE,
na = "")
# Simulated rv list ####
rv <- {list(
  file_upload_encrypt = cbind.data.frame(datapath = paste0(tempdir(),
  "/test.csv"))
)}
# Perform file encryption ####
encryption_results <- EQUAL_perform_file_encryption(rv,
server_address = tempdir())
# Simulate what happens prior to user input for decryption ####
# The encrypted files are unzipped and the individual files are shared
unzipped_files_folder <- paste0(tempfile(), "/unzipped_files")
dir.create(unzipped_files_folder, recursive = TRUE)
zip::unzip(encryption_results$encrypted_file_path,
exdir = unzipped_files_folder)
zip::unzip(paste0(unzipped_files_folder, "/publicly_shareable.zip"),
exdir = unzipped_files_folder)
zip::unzip(paste0(unzipped_files_folder, "/not_publicly_shareable.zip"),
exdir = unzipped_files_folder)
# Simulated rv list for decryption
rv <- {list(
  file_upload_decrypt = cbind.data.frame(datapath =
  paste0(unzipped_files_folder, "encrypted_file.RDS")),
  signature_upload = cbind.data.frame(datapath =
  paste0(unzipped_files_folder, "signature.RDS")),
  public_keys_upload = cbind.data.frame(datapath =
  paste0(unzipped_files_folder, "public_encryption_key.txt")),
  private_keys_upload = cbind.data.frame(datapath =
  paste0(unzipped_files_folder, "private_encryption_key.txt"))
)}
results <- EQUAL_perform_file_decryption(rv)

Run the code above in your browser using DataLab