R/gen_passwd.R

Defines functions gen_passwd

Documented in gen_passwd

#' Generate a password from random characters
#' @param length Length of the Password; integer
#' @return password with the size of `length` argument
#' @export
gen_passwd <- function(length = 16L) {
  if (is.null(length)) {
    length <- 16L
  }
  if (!isTRUE(is.numeric(length))) {
    length <- 16L
  }
  char_vector <- c(
    LETTERS,
    letters,
    0:9,
    "!", ",", ".", "|", "@", "#", "$", "%", "&", "*"
  )
  paste0(
    sample(x = char_vector, size = length, replace = TRUE),
    collapse = ""
  )
}
luciorq/luciolib documentation built on Dec. 18, 2020, 11:43 a.m.