spsEncryption: SPS encryption functions

Description Super class Methods Examples

Description

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.

Super class

systemPipeShiny::spsDb -> spsEncryption

Methods

Public methods

Inherited methods

Method new()

initialize a new class container

Usage
spsEncryption$new()

Method keyChange()

Change encryption key of a SPS project

Usage
spsEncryption$keyChange(confirm = FALSE, db_name = "config/sps.db")
Arguments
confirm,

bool, confirm that you understand the consequence

db_name

database path


Method keyGet()

Get encryption key from db of a SPS project

Usage
spsEncryption$keyGet(db_name = "config/sps.db")
Arguments
db_name

database path


Method encrypt()

Encrypt raw data or a file with key from a SPS project

Usage
spsEncryption$encrypt(
  data,
  out_path = NULL,
  overwrite = FALSE,
  db_name = "config/sps.db"
)
Arguments
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


Method decrypt()

Decrypt raw data or a file with key from a SPS project

Usage
spsEncryption$decrypt(
  data,
  out_path = NULL,
  overwrite = FALSE,
  db_name = "config/sps.db"
)
Arguments
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


Method clone()

The objects of this class are cloneable with this method.

Usage
spsEncryption$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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')

systemPipeR/systemPipeShiny documentation built on June 1, 2021, 6:42 a.m.