pw: XKCD-style Password Generation

Description Usage Arguments Details Examples

Description

The function uses a random Wikipedia page to generate a portmanteau password, as in the XKCD comic https://m.xkcd.com/936/ .

Usage

1
2
  password(pw.len=4, min.len=4, max.len=12, language="english", ..., 
  num.scrapes=1, ret.type="separate")

Arguments

pw.len

Number of words to use in the password. Default is 4, as in the comic.

min.len

Minimum word length for each word in the portmanteau.

max.len

Maximum word length for each word in the portmanteau.

language

The language the resulting password will be in.

...

Extra arguments.

num.scrapes

The number of Wikipedia scrapes to perform for a single password generation. Must be between 1 and 5.

ret.type

Controls the format of the returned password; options are "separate" or "combined", with the former being the default.

Details

The function password() forms a portmanteau password, inspired by XKCD comic number 936. Rather than using a dictionary, however, we use a random Wikipedia page as our word source.

By default, the password will be a portmanteau made up of 4 words randomly selected from a random Wikipedia page. You may change this number to another (sensible) choice via the argument pw.len=. The arguments min.len= and max.len= refer to the length of each word in the portmanteau, rather than the length of the final password.

The language= argument specifies which Wikipedia pages will be scraped. Currently, options are:

This argument is case-insensitive.

The optional argument num.scrapes= determines the number of Wikipedia pages to scrape for a given password generation. The default is 1, which should be fine almost every time; if not, make sure min.len= isn't set to something stupid and try again. Note that num.scrapes= is limited to a maximum of 5; much more than that really should not improve the password, and it just needlessly hammers Wikipedia (which might get your ip banned). It would also really slow the scrubbing to a crawl.

Finally, it should be noted that the function requires an internet connection, as a new, random Wikipedia page is scraped each time the function is evaluated.

Examples

1
2
3
4
5
6
## Not run: 
library(xkcdpw, quietly=TRUE)

password()

## End(Not run)

wrathematics/xkcdpw documentation built on May 4, 2019, 10:54 a.m.