R/gen_keys.R

Defines functions gen_sodium_key gen_aes_key

Documented in gen_aes_key gen_sodium_key

#' @title Generate aes or libsodium key
#'
#' @param ...
#' arguments to pass to `openssl::aes_keygen()` or `sodium::keygen()`
#' @return
#' A `cyphr` key object for use with `deidentify_id()` and identify_id functions
#' @importFrom sodium keygen
#' @importFrom openssl aes_keygen
#'
#' @examples
#' \dontrun{gen_aes_key(12)}
#' @export
gen_aes_key <- function(...) {
  cykey <- cyphr::key_openssl(key = aes_keygen(...))
  return(cykey)
}


#' @title Generate sodium key
#' @param ...
#' arguments to pass to `openssl::aes_keygen()` or `sodium::keygen()`
#'
#' @return
#' A `cyphr` key object for use with `deidentify_id()` and identify_id functions
#' @export
#'
#' @examples
#' \dontrun{key_sodium(12)}
gen_sodium_key <- function(...) {
  sodkey <- cyphr::key_sodium(key = sodium::keygen(...))
  return(sodkey)
}
phillydao/deidentify documentation built on Feb. 4, 2021, 2:31 p.m.