key_functions: Key Functions

Description Usage Arguments Details Value Examples

Description

ONE-LINER WHAT DO THESE GROUP OF FUNCS DO? (or the name of the main function)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
show_default_rcreds_key_file()

create_key(bytes = 32, depth = 8, seed = NULL, showWarnings = TRUE,
  verbose = getOption("verbose.rcreds", default = TRUE))

is.key_rcreds(key)

save_key(file_full_path = file.path(folder, file_name),
  file_name = getOption("rcreds.key.file_name", default = ".crypt_key.rds"),
  folder = get_default_rcreds_key_folder(), key, bytes = 32, depth = 8,
  seed = NULL, zArchive_existing = TRUE, overwrite_existing = FALSE,
  showWarnings = TRUE, allow_root_user = FALSE,
  verbose = getOption("verbose.rcreds", default = TRUE))

read_key_from_file(file_full_path = file.path(folder, file_name),
  file_name = getOption("rcreds.key.file_name", default = ".crypt_key.rds"),
  folder = get_default_rcreds_key_folder(), create_if_not_exist = TRUE,
  showWarnings = FALSE, verbose = getOption("verbose.rcreds", default =
  TRUE))

Arguments

bytes

Number of bytes used for the key. Values should normally be one of c(16, 24, 32)

Defaults to: 32

depth

Bit depth for key.

Defaults to: 8

seed

An integer passed to set.seed() Generating the key involves random number generation. Setting the seed will make the key determenistic.

Defaults to: NULL

showWarnings

A TRUE/FALSE flag. If FALSE, warnings will be silenced

Defaults to: TRUE

verbose

A TRUE/FALSE flag.

Defaults to: getOption(\"verbose.rcreds\", default = TRUE)

key

A key object of class "key_rcreds" to be used for encrypting / decrypting. Passed to digest::AES.

Alternatively, a full file path to a key stored on disk can be given which will be read to disk.

file_full_path

The full path to the creds (or key) file, where it should be read from or written to. if "..auto.." then will be constructed from folder, file_name, and info.file_name

NOTE: When file_full_path is set explicitly, then folder, file_name, and info.file_name are ignored.

Defaults to: file.path(folder, file_name)

file_name

name of the file where the key will be written to or read from. Should be a string of length 1

Defaults to: getOption(\"rcreds.key.file_name\", default = \".crypt_key.rds\")

folder

folder where the credentials will be written to or read from.

Defaults to: get_default_rcreds_key_folder()

zArchive_existing

A TRUE/FALSE flag. If file_full_path already exist, should it be moved to a zArchive folder?

Defaults to: TRUE

overwrite_existing

A TRUE/FALSE flag. If file_full_path already exist, should it be overwritten? This is only considered when zArchive_existing is FALSE

Defaults to: FALSE

allow_root_user

A TRUE/FALSE flag. If FALSE and user is root, then writing and saving functions will fail This is a safety to make sure the user understands they are operating under root.

Defaults to: FALSE

create_if_not_exist

A TRUE/FALSE flag. for read_key_from_file: If the given file does not exist, should a key be created and stored at that location?

Defaults to: TRUE

Details

DETAILED DESCRIPTION of what these functions do

Value

for create_key and read_key_from_file: An object of class key_rcreds

for save_key and show_default_rcreds_key_file: A full file path. In the case of save_key, this is where the key has been written to.

for is.key_rcreds: A TRUE/FALSE value indidcating if the input is of class "key_rcreds"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 ## Not run: 
   ### ---------------------------------------------- ###
   ## Default Folders need to be set. This shold be in an .Rprofile file
   ### ---------------------------------------------- ###
   ## generally use:  set_default_rcreds_ALL(parent_folder = "~/.rcreds/")
   set_default_rcreds_ALL(parent_folder = file.path(tempdir(), ".rcreds/"), 
                          create_if_not_exist = TRUE)
   ### ---------------------------------------------- ###

   library(rcreds)

   key <- create_key()

   file_creds <- write_credentials_to_file(username="cosmo", password="too many secrets", key=key)
   file_key   <- save_key(folder="different/key/location")

   ### IN ANOTHER FILE
   key <- read_key_from_file(folder="different/key/location")
   creds <- read_credentials_from_file(key=key, fail_if_cant_decrypt=FALSE, showWarnings=FALSE)
   ## normally, leave the above flags as their default TRUE. Using FALSE for this example only.
 
## End(Not run)

rcreds documentation built on May 2, 2019, 9:25 a.m.