R/encrypt_data.R

Defines functions encrypt_data

Documented in encrypt_data

#' Encrypt and save and .RData file
#'
#' @param data data structure to encrypt
#' @param password password to encrypt/decrypt the file
#' @param saveLocation location to save the .RData file
#'
encrypt_data <- function(data,password,saveLocation){
  nonce <- random(24)
  key <- hash(charToRaw(password))

  msg <- serialize(data, NULL)
  cipher <- data_encrypt(msg, key, nonce)

  encrypted <- cipher
  save(encrypted,file=saveLocation)
}
OpenSourceMindshare/surveytools documentation built on Aug. 14, 2019, 10:38 a.m.