Sometimes we need not only secure passwords but also passwords easy to remember. PasswordGen is an R package that helps you generates passwords and passphrases easy to remember with an algorithm based on the dictionary method.
The default password()
function generates random passwords using words from
The Project Gutenberg EBook of Webster's Unabridged Dictionary,
by Various. In total 93077 words are used.
However, you can use the ExtractWords()
function to extract all the words from
any book and use them in the password()
generator.
Check the examples provided in the help files of the package.
devtools::install_github("mpascariu/PasswordGen")
If you do not have devtools, you can install it from CRAN, by typing install.packages("devtools")
.
Alternatively, clone or download the repository to a local directory and install it by running install.packages(<local_dir>, repos = NULL, type = "source")
.
All functions are documented in the standard way, which means that
once you load the package using library(PasswordGen)
you can just type ?password
to see the help file.
Generate passwords and passphrases using \code{password} function.
library(PasswordGen) password()
The default version of the function is generating a string that containts three words (lower and upper cases) plus some random symbols and numbers. As mentioned above the words are borrowed from Webster's Unabridged Dictionary.
We may want to change increase or decrease the complexity of our passwords. We can do this by playing with the arguments of the \code{passwords} function.
Let's generate a passphrase composed out of 5 words plus a random number after each word, no symbols, and separate them using a dash line.
password(no_words = 5, # 5 word password numbers = TRUE, # with numbers symbols = FALSE, # without symbols sep = '-') # with a space between the words
Generate a password using words from my favorite book.
Using the \code{gutenbergr} R package we will download a book and extract words from it. "The Adventures of Sherlock Holmes" by Doyle, Arthur Conan is a good choice.
library(gutenbergr) library(stringr) # look up book and check the id on Gutenberg Project info <- gutenberg_works(str_detect(title, "The Adventures of Sherlock Holmes")) info$gutenberg_id # this should be 1661 # download the book my_book <- gutenberg_download(gutenberg_id = 1661, meta_fields = "title", mirror = "http://gutenberg.pglaf.org")
Now we can extract the words using the \code{ExtractWords} function.
words <- ExtractWords(data.r = my_book$text) words # Note, this book has significantly less unique words than Webster's Unabridged Dictionary. More words to choose from is better.
And generate the password:
password(no_words = 5, data = words)
Extract words from other language than English and generate passwords. Mihai Eminescu was a Romantic poet, often regarded as the most famous and influential Romanian poet. Let's check his words.
# check the id of the book on Gutenberg Project info <- gutenberg_works(languages = 'ro') # download the book my_book <- gutenberg_download(gutenberg_id = 35323, meta_fields = "title", mirror = "http://gutenberg.pglaf.org") # Extract words words <- ExtractWords(data.r = my_book$text) password(no_words = 4, data = words, numbers = TRUE, symbols = TRUE, sep = "_")
Nice Romanian password!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.