spsEncryption | R Documentation |
Methods in this class can help admin to encrypt files been output from sps.
For now it is only used to encypt and decrypt snapshots.
This class requires the SPS database. This class inherits all functions from
the spsDb class, so there is no need to initiate the spsDb
container.
This class is required to run a SPS app. This class needs to be initialized global level. This has already been written in global.R for you.
systemPipeShiny::spsDb
-> spsEncryption
new()
initialize a new class container
spsEncryption$new()
keyChange()
Change encryption key of a SPS project
spsEncryption$keyChange(confirm = FALSE, db_name = "config/sps.db")
confirm,
bool, confirm that you understand the consequence
db_name
database path
keyGet()
Get encryption key from db of a SPS project
spsEncryption$keyGet(db_name = "config/sps.db")
db_name
database path
encrypt()
Encrypt raw data or a file with key from a SPS project
spsEncryption$encrypt( data, out_path = NULL, overwrite = FALSE, db_name = "config/sps.db" )
data
raw vector or a file path
out_path
if provided, encrypted data will be write to a file
overwrite
if out_path
file exists, overwrite?
db_name
database path
decrypt()
Decrypt raw data or a file with key from a SPS project
spsEncryption$decrypt( data, out_path = NULL, overwrite = FALSE, db_name = "config/sps.db" )
data
raw vector or a file path
out_path
if provided, encrypted data will be write to a file
overwrite
if out_path
file exists, overwrite?
db_name
database path
clone()
The objects of this class are cloneable with this method.
spsEncryption$clone(deep = FALSE)
deep
Whether to make a deep clone.
dir.create("config", showWarnings = FALSE)
spsOption('verbose', TRUE)
my_ecpt <- spsEncryption$new()
my_ecpt$createDb()
# Read carefully before change the key
my_ecpt$keyChange()
# confirm
my_ecpt$keyChange(confirm = TRUE)
# imagine a file has one line "test"
writeLines(text = "test", con = "test.txt")
# encrypt the file
my_ecpt$encrypt("test.txt", "test.bin", overwrite = TRUE)
# decrypt the file
my_ecpt$decrypt("test.bin", "test_decpt.txt", overwrite = TRUE)
# check the decrypted file content
readLines('test_decpt.txt')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.