library(yaml)
library(sodium)
##
## Set & save password to encrypt config list and hashed pwd check
##
set_new_encrypted <- function(pwd = NULL, run_build=TRUE){
if(is.null(pwd))
pwd <- rstudioapi::askForPassword("Save new password:")
if(!is.null(pwd)){
##
## save password just receieved
##
key <- sodium::sha256(charToRaw(pwd))
saveRDS(sodium::password_store(pwd), file = "inst/temp/hash_pwd")
## read and store config yml file as encrypted binary
##
hpds <- readLines("private/hdps_yml")
hpds_list <- yaml::yaml.load(paste0(hpds, collapse = "\n"))
config_ciph <- sodium::data_encrypt(serialize(hpds_list, NULL), key)
saveRDS(config_ciph, "inst/temp/config_ciph")
if(run_build) devtools::document()
return(TRUE)
}
return(FALSE)
}
set_new_encrypted("Newyork1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.