# function for encrypting a password
pwdEncrypt <- function(password, key){
require(PKI)
pwdRaw <- charToRaw(password)
pwdEncrypted <-PKI.encrypt(pwdRaw, key)
return(pwdEncrypted)
}
# function for decrypting a password
pwdDecrypt <- function(encrypted_password, key){
require(PKI)
pwdRaw <- PKI.decrypt(encrypted_password, key)
pwd <- rawToChar(pwdRaw)
return(pwd)
}
# function to save encrypted password
pwdSaveRDS <- function(encrypted_password, file, location){
require(PKI)
if(missing(location)){
location <- getwd()
location_file <- paste0(location, "/", file)
saveRDS(object = encrypted_password, file = location_file)
return(print(paste0("Password saved as: '", location_file, "' ")))
} else {
location_file <- paste0(location, "/", file)
saveRDS(object = encrypted_password, file = location_file)
return(print(paste0("Password saved as: '", location_file, "' ")))
}
}
# function to load encrypted password
pwdLoadRDS <- function(location_file){
require(PKI)
pwd <- readRDS(location_file)
return(pwd)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.