R/generatePassword.R

generatePassword <- function(nchar){
  if(missing(nchar))  nchar <- 8

  punctation <- strsplit(c("! # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \\ ] ^ _ ` { | } ~ \"")," ")[[1]]
  char_set <-
    c(punctation,
      LETTERS, letters,
      0:9)
  return(paste0(sample(char_set,nchar), collapse=""))
}
gogonzo/oddsandsods documentation built on May 12, 2019, 1:35 a.m.