Learn R Programming

PKI (version 0.1-14)

PKI.genpass: Generate cryptographically strong pseudo-random password.

Description

PKI.genpass generates n cryptographically strong pseudo-random password by using a given set of allowed characters.

Usage

PKI.genpass(n=15, set=c(alphanum, ".", "/"), block=5, sep="-")

Value

String, generated password.

Arguments

n

positive integer, number of random elements in the password

set

character vector, set of characters to use in the password, ideally its length should be a power of 2 and must be at most 256. Internal variable alphanum is equivalent to c(LETTERS, letters, 0:9).

block

non-negative integer, number of character blocks in the password or 0 if no separated blocks are desired.

sep

string, separator between blocks (only used if 0 < blocks < n).

Author

Simon Urbanek

Details

PKI.genpass generates a password based on a set of allowable characters by subsetting the set with bytes generated using PKI.random.

If block is >0 and <n then blocks of block characters are separated by the separator string sep. This is typically used to guarantee at least one special character in the password. The default results in a 90-bit random password of the form XXXXX-XXXXX-XXXXX.

Examples

Run this code
  PKI.genpass()

Run the code above in your browser using DataLab