library(hidePwd)
# create a key
db_key <- createPwdKey()
# encrypt a password
password_encrypted <- pwdEncrypt("HbgqeM#*CQ#!9", db_key)
# (optional) check the encrypted password
password_encrypted
# save the encrypted password
# ! needs to be saved as RDS
# pwdSaveRDS(password_encrypted, "db_password_encrypted.rds")
# save the key that is needed to decrypt the password
#saveKeyRDS(db_key, "db_password_key.rds", getwd())
saveKeyRSA(key = db_key, "db_key.rsa")
#### Other R Session
# import the encrypted password
encrypted_password <- pwdLoadRDS("db_password_encrypted.rds")
# import key to decrypt password
# key_db <- readKeyRDS("db_password_key.rds")
# import rsa key to decrypt password
# use a different variable name to make sure the imported key works
key_db <- readKeyRSA("db_key.rsa")
# (optional) show encrypted password
encrypted_password
# decrypt encrypted password with the imported key
db_password <- pwdDecrypt(encrypted_password, key_db)
#test
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.