Last active
January 19, 2018 19:17
-
-
Save bestie/f682428bdc3785c57b382eca6f570fbc to your computer and use it in GitHub Desktop.
Memorable, secure password generator in one file. XKCD style, includes 1765 common words.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "optparse" | |
options = { | |
:n_passwords => 1, | |
:password_length => 4, | |
:separator => " ", | |
} | |
parser = OptionParser.new do|opts| | |
opts.banner = "Usage: generate_password [options]" | |
opts.on("-n", "--npasswords NUMBER", "Number of passwords to generate") do |n_passwords| | |
options[:n_passwords] = Integer(n_passwords) | |
end | |
opts.on("-l", "--length-in-words NUMBER", "Number of words per password (default 4)") do |password_length| | |
options[:password_length] = Integer(password_length) | |
end | |
opts.on("-s", "--separator STRING", "Character to separate words (default space)") do |separator| | |
options[:separator] = separator | |
end | |
opts.on("-h", "--help", "Displays Help") do | |
puts opts | |
exit | |
end | |
end.parse! | |
n_passwords = options.fetch(:n_passwords) | |
length_in_words = options.fetch(:password_length) | |
separator = options.fetch(:separator) | |
word_list = DATA.readlines.map(&:chomp) | |
n_passwords.times do | |
random_words = word_list.sample(length_in_words) | |
puts random_words.join(separator) | |
end | |
__END__ | |
ability | |
able | |
about | |
above | |
absence | |
absolutely | |
academic | |
accept | |
access | |
accident | |
accompany | |
according | |
account | |
achieve | |
achievement | |
acid | |
acquire | |
across | |
act | |
action | |
active | |
activity | |
actual | |
actually | |
add | |
addition | |
additional | |
address | |
administration | |
admit | |
adopt | |
adult | |
advance | |
advantage | |
advice | |
advise | |
affair | |
affect | |
afford | |
afraid | |
after | |
afternoon | |
afterwards | |
again | |
against | |
age | |
agency | |
agent | |
ago | |
agree | |
agreement | |
ahead | |
aid | |
aim | |
air | |
aircraft | |
all | |
allow | |
almost | |
alone | |
along | |
already | |
alright | |
also | |
alternative | |
although | |
always | |
among | |
amongst | |
amount | |
analysis | |
ancient | |
and | |
animal | |
announce | |
annual | |
another | |
answer | |
any | |
anybody | |
anyone | |
anything | |
anyway | |
apart | |
apparent | |
apparently | |
appeal | |
appear | |
appearance | |
application | |
apply | |
appoint | |
appointment | |
approach | |
appropriate | |
approve | |
area | |
argue | |
argument | |
arise | |
arm | |
army | |
around | |
arrange | |
arrangement | |
arrive | |
art | |
article | |
artist | |
ask | |
aspect | |
assembly | |
assess | |
assessment | |
asset | |
associate | |
association | |
assume | |
assumption | |
atmosphere | |
attach | |
attack | |
attempt | |
attend | |
attention | |
attitude | |
attract | |
attractive | |
audience | |
author | |
authority | |
available | |
average | |
avoid | |
award | |
aware | |
away | |
aye | |
baby | |
back | |
background | |
bad | |
bag | |
balance | |
ball | |
band | |
bank | |
bar | |
base | |
basic | |
basis | |
battery | |
battle | |
bear | |
beat | |
beautiful | |
because | |
become | |
bed | |
bedroom | |
before | |
begin | |
beginning | |
behaviour | |
behind | |
belief | |
believe | |
belong | |
below | |
beneath | |
benefit | |
beside | |
best | |
better | |
between | |
beyond | |
big | |
bill | |
bind | |
bird | |
birth | |
bit | |
black | |
block | |
blood | |
bloody | |
blow | |
blue | |
board | |
boat | |
body | |
bone | |
book | |
boop | |
border | |
both | |
bottle | |
bottom | |
box | |
boy | |
brain | |
branch | |
break | |
breath | |
bridge | |
brief | |
bright | |
bring | |
broad | |
brother | |
budget | |
build | |
building | |
burn | |
bus | |
business | |
busy | |
but | |
buy | |
cabinet | |
call | |
campaign | |
can | |
candidate | |
capable | |
capacity | |
capital | |
car | |
card | |
care | |
career | |
careful | |
carefully | |
carry | |
case | |
cash | |
cat | |
catch | |
category | |
cause | |
cell | |
central | |
centre | |
century | |
certain | |
certainly | |
chain | |
chair | |
chairman | |
challenge | |
chance | |
change | |
channel | |
chapter | |
character | |
characteristic | |
charge | |
cheap | |
check | |
chemical | |
chief | |
child | |
choice | |
choose | |
church | |
circle | |
circumstance | |
citizen | |
city | |
civil | |
claim | |
class | |
clean | |
clear | |
clearly | |
client | |
climb | |
close | |
closely | |
clothes | |
club | |
coal | |
code | |
coffee | |
cold | |
colleague | |
collect | |
collection | |
college | |
colour | |
combination | |
combine | |
come | |
comment | |
commercial | |
commission | |
commit | |
commitment | |
committee | |
common | |
communication | |
community | |
company | |
compare | |
comparison | |
competition | |
complete | |
completely | |
complex | |
component | |
computer | |
concentrate | |
concentration | |
concept | |
concern | |
concerned | |
conclude | |
conclusion | |
condition | |
conduct | |
conference | |
confidence | |
confirm | |
conflict | |
congress | |
connect | |
connection | |
consequence | |
conservative | |
consider | |
considerable | |
consideration | |
consist | |
constant | |
construction | |
consumer | |
contact | |
contain | |
content | |
context | |
continue | |
contract | |
contrast | |
contribute | |
contribution | |
control | |
convention | |
conversation | |
copy | |
corner | |
corporate | |
correct | |
cos | |
cost | |
could | |
council | |
count | |
country | |
county | |
couple | |
course | |
court | |
cover | |
create | |
creation | |
credit | |
crime | |
criminal | |
crisis | |
criterion | |
critical | |
criticism | |
cross | |
crowd | |
cry | |
cultural | |
culture | |
cup | |
current | |
currently | |
curriculum | |
customer | |
cut | |
damage | |
danger | |
dangerous | |
dark | |
data | |
date | |
daughter | |
day | |
dead | |
deal | |
death | |
debate | |
debt | |
decade | |
decide | |
decision | |
declare | |
deep | |
defence | |
defendant | |
define | |
definition | |
degree | |
deliver | |
demand | |
democratic | |
demonstrate | |
deny | |
department | |
depend | |
deputy | |
derive | |
describe | |
description | |
design | |
desire | |
desk | |
despite | |
destroy | |
detail | |
detailed | |
determine | |
develop | |
development | |
device | |
die | |
difference | |
different | |
difficult | |
difficulty | |
dinner | |
direct | |
direction | |
directly | |
director | |
disappear | |
discipline | |
discover | |
discuss | |
discussion | |
disease | |
display | |
distance | |
distinction | |
distribution | |
district | |
divide | |
division | |
doctor | |
document | |
dog | |
domestic | |
door | |
double | |
doubt | |
down | |
draw | |
drawing | |
dream | |
dress | |
drink | |
drive | |
driver | |
drop | |
drug | |
dry | |
due | |
during | |
duty | |
each | |
ear | |
early | |
earn | |
earth | |
easily | |
east | |
easy | |
eat | |
economic | |
economy | |
edge | |
editor | |
education | |
educational | |
effect | |
effective | |
effectively | |
effort | |
egg | |
either | |
elderly | |
election | |
element | |
else | |
elsewhere | |
emerge | |
emphasis | |
employ | |
employee | |
employer | |
employment | |
empty | |
enable | |
encourage | |
end | |
enemy | |
energy | |
engine | |
engineering | |
enjoy | |
enough | |
ensure | |
enter | |
enterprise | |
entire | |
entirely | |
entitle | |
entry | |
environment | |
environmental | |
equal | |
equally | |
equipment | |
error | |
escape | |
especially | |
essential | |
establish | |
establishment | |
estate | |
estimate | |
even | |
evening | |
event | |
eventually | |
ever | |
every | |
everybody | |
everyone | |
everything | |
evidence | |
exactly | |
examination | |
examine | |
example | |
excellent | |
except | |
exchange | |
executive | |
exercise | |
exhibition | |
exist | |
existence | |
existing | |
expect | |
expectation | |
expenditure | |
expense | |
expensive | |
experience | |
experiment | |
expert | |
explain | |
explanation | |
explore | |
express | |
expression | |
extend | |
extent | |
external | |
extra | |
extremely | |
eye | |
face | |
facility | |
fact | |
factor | |
factory | |
fail | |
failure | |
fair | |
fairly | |
faith | |
fall | |
familiar | |
family | |
famous | |
far | |
farm | |
farmer | |
fashion | |
fast | |
father | |
favour | |
fear | |
feature | |
fee | |
feel | |
feeling | |
female | |
few | |
field | |
fight | |
figure | |
file | |
fill | |
film | |
final | |
finally | |
finance | |
financial | |
find | |
finding | |
fine | |
finger | |
finish | |
fire | |
firm | |
first | |
fish | |
fit | |
fix | |
flat | |
flight | |
floor | |
flow | |
flower | |
fly | |
focus | |
follow | |
following | |
food | |
foot | |
football | |
for | |
force | |
foreign | |
forest | |
forget | |
form | |
formal | |
former | |
forward | |
foundation | |
free | |
freedom | |
frequently | |
fresh | |
friend | |
from | |
front | |
fruit | |
fuel | |
full | |
fully | |
function | |
fund | |
funny | |
further | |
future | |
gain | |
game | |
garden | |
gas | |
gate | |
gather | |
general | |
generally | |
generate | |
generation | |
gentleman | |
get | |
girl | |
give | |
glass | |
goal | |
god | |
gold | |
good | |
government | |
grant | |
great | |
green | |
grey | |
ground | |
group | |
grow | |
growing | |
growth | |
guest | |
guide | |
gun | |
hair | |
half | |
hall | |
hand | |
handle | |
hang | |
happen | |
happy | |
hard | |
hardly | |
hate | |
have | |
head | |
health | |
hear | |
heart | |
heat | |
heavy | |
hell | |
help | |
hence | |
her | |
here | |
herself | |
hide | |
high | |
highly | |
hill | |
him | |
himself | |
his | |
historical | |
history | |
hit | |
hold | |
hole | |
holiday | |
home | |
hope | |
horse | |
hospital | |
hot | |
hotel | |
hour | |
house | |
household | |
housing | |
how | |
however | |
huge | |
human | |
hurt | |
husband | |
idea | |
identify | |
ignore | |
illustrate | |
image | |
imagine | |
immediate | |
immediately | |
impact | |
implication | |
imply | |
importance | |
important | |
impose | |
impossible | |
impression | |
improve | |
improvement | |
incident | |
include | |
including | |
income | |
increase | |
increased | |
increasingly | |
indeed | |
independent | |
index | |
indicate | |
individual | |
industrial | |
industry | |
influence | |
inform | |
information | |
initial | |
initiative | |
injury | |
inside | |
insist | |
instance | |
instead | |
institute | |
institution | |
instruction | |
instrument | |
insurance | |
intend | |
intention | |
interest | |
interested | |
interesting | |
internal | |
international | |
interpretation | |
interview | |
into | |
introduce | |
introduction | |
investigate | |
investigation | |
investment | |
invite | |
involve | |
iron | |
island | |
issue | |
item | |
its | |
itself | |
job | |
join | |
joint | |
journey | |
judge | |
jump | |
just | |
justice | |
keep | |
key | |
kid | |
kill | |
kind | |
king | |
kitchen | |
knee | |
know | |
knowledge | |
labour | |
lack | |
lady | |
land | |
language | |
large | |
largely | |
last | |
late | |
later | |
latter | |
laugh | |
launch | |
law | |
lawyer | |
lay | |
lead | |
leader | |
leadership | |
leading | |
leaf | |
league | |
lean | |
learn | |
least | |
leave | |
left | |
leg | |
legal | |
legislation | |
length | |
less | |
let | |
letter | |
level | |
liability | |
liberal | |
library | |
lie | |
life | |
lift | |
light | |
like | |
likely | |
limit | |
limited | |
line | |
link | |
lip | |
list | |
listen | |
literature | |
little | |
live | |
living | |
loan | |
local | |
location | |
long | |
look | |
lord | |
lose | |
loss | |
lot | |
love | |
lovely | |
low | |
lunch | |
machine | |
magazine | |
main | |
mainly | |
maintain | |
major | |
majority | |
make | |
male | |
man | |
manage | |
management | |
manager | |
manner | |
many | |
map | |
mark | |
market | |
marriage | |
married | |
marry | |
mass | |
master | |
match | |
material | |
matter | |
may | |
maybe | |
meal | |
mean | |
meaning | |
means | |
meanwhile | |
measure | |
mechanism | |
media | |
medical | |
meet | |
meeting | |
member | |
membership | |
memory | |
mental | |
mention | |
merely | |
message | |
metal | |
method | |
middle | |
might | |
mile | |
military | |
milk | |
mind | |
mine | |
minister | |
ministry | |
minute | |
miss | |
mistake | |
model | |
modern | |
module | |
moment | |
money | |
month | |
more | |
morning | |
most | |
mother | |
motion | |
motor | |
mountain | |
mouth | |
move | |
movement | |
much | |
murder | |
museum | |
music | |
must | |
myself | |
name | |
narrow | |
nation | |
national | |
natural | |
nature | |
near | |
nearly | |
necessarily | |
necessary | |
neck | |
need | |
negotiation | |
neighbour | |
neither | |
network | |
never | |
nevertheless | |
new | |
news | |
newspaper | |
next | |
nice | |
night | |
no-one | |
nobody | |
nod | |
noise | |
none | |
nor | |
normal | |
normally | |
north | |
northern | |
nose | |
not | |
note | |
nothing | |
notice | |
notion | |
now | |
nuclear | |
number | |
nurse | |
object | |
objective | |
observation | |
observe | |
obtain | |
obvious | |
obviously | |
occasion | |
occur | |
odd | |
off | |
offence | |
offer | |
office | |
officer | |
official | |
often | |
oil | |
okay | |
old | |
once | |
one | |
only | |
onto | |
open | |
operate | |
operation | |
opinion | |
opportunity | |
opposition | |
option | |
order | |
ordinary | |
organisation | |
organise | |
organization | |
origin | |
original | |
other | |
otherwise | |
ought | |
our | |
ourselves | |
out | |
outcome | |
output | |
outside | |
over | |
overall | |
own | |
owner | |
package | |
page | |
pain | |
paint | |
painting | |
pair | |
panel | |
paper | |
parent | |
park | |
parliament | |
part | |
particular | |
particularly | |
partly | |
partner | |
party | |
pass | |
passage | |
past | |
path | |
patient | |
pattern | |
pay | |
payment | |
peace | |
pension | |
people | |
per | |
percent | |
perfect | |
perform | |
performance | |
perhaps | |
period | |
permanent | |
person | |
personal | |
persuade | |
phase | |
phone | |
photograph | |
physical | |
pick | |
picture | |
piece | |
place | |
plan | |
planning | |
plant | |
plastic | |
plate | |
play | |
player | |
please | |
pleasure | |
plenty | |
plus | |
point | |
police | |
policy | |
political | |
politics | |
pool | |
poor | |
popular | |
population | |
position | |
positive | |
possibility | |
possible | |
possibly | |
post | |
potential | |
pound | |
power | |
powerful | |
practical | |
practice | |
prefer | |
prepare | |
presence | |
present | |
president | |
press | |
pressure | |
pretty | |
prevent | |
previous | |
previously | |
price | |
primary | |
prime | |
principle | |
priority | |
prison | |
prisoner | |
private | |
probably | |
problem | |
procedure | |
process | |
produce | |
product | |
production | |
professional | |
profit | |
program | |
programme | |
progress | |
project | |
promise | |
promote | |
proper | |
properly | |
property | |
proportion | |
proposal | |
propose | |
prospect | |
protect | |
protection | |
prove | |
provide | |
provided | |
provision | |
pub | |
public | |
publication | |
publish | |
pull | |
pupil | |
purpose | |
push | |
put | |
quality | |
quarter | |
question | |
quick | |
quickly | |
quiet | |
quite | |
race | |
radio | |
railway | |
rain | |
raise | |
range | |
rapidly | |
rare | |
rate | |
rather | |
reach | |
reaction | |
read | |
reader | |
reading | |
ready | |
real | |
realise | |
reality | |
realize | |
really | |
reason | |
reasonable | |
recall | |
receive | |
recent | |
recently | |
recognise | |
recognition | |
recognize | |
recommend | |
record | |
recover | |
red | |
reduce | |
reduction | |
refer | |
reference | |
reflect | |
reform | |
refuse | |
regard | |
region | |
regional | |
regular | |
regulation | |
reject | |
relate | |
relation | |
relationship | |
relative | |
relatively | |
release | |
relevant | |
relief | |
religion | |
religious | |
rely | |
remain | |
remember | |
remind | |
remove | |
repeat | |
replace | |
reply | |
report | |
represent | |
representation | |
representative | |
request | |
require | |
requirement | |
research | |
resource | |
respect | |
respond | |
response | |
responsibility | |
responsible | |
rest | |
restaurant | |
result | |
retain | |
return | |
reveal | |
revenue | |
review | |
revolution | |
rich | |
ride | |
right | |
ring | |
rise | |
risk | |
river | |
road | |
rock | |
role | |
roll | |
roof | |
room | |
round | |
route | |
row | |
royal | |
rule | |
run | |
rural | |
safe | |
safety | |
sale | |
same | |
sample | |
satisfy | |
save | |
say | |
scale | |
scene | |
scheme | |
school | |
science | |
scientific | |
scientist | |
score | |
screen | |
sea | |
search | |
season | |
seat | |
second | |
secondary | |
secretary | |
section | |
sector | |
secure | |
security | |
see | |
seek | |
seem | |
select | |
selection | |
sell | |
send | |
senior | |
sense | |
sentence | |
separate | |
sequence | |
series | |
serious | |
seriously | |
servant | |
serve | |
service | |
session | |
set | |
settle | |
settlement | |
several | |
severe | |
sex | |
sexual | |
shake | |
shall | |
shape | |
share | |
she | |
sheet | |
ship | |
shoe | |
shoot | |
shop | |
short | |
shot | |
should | |
shoulder | |
shout | |
show | |
shut | |
side | |
sight | |
sign | |
signal | |
significance | |
significant | |
silence | |
similar | |
simple | |
simply | |
since | |
sing | |
single | |
sir | |
sister | |
sit | |
site | |
situation | |
size | |
skill | |
skin | |
sky | |
sleep | |
slightly | |
slip | |
slow | |
slowly | |
small | |
smile | |
social | |
society | |
soft | |
software | |
soil | |
soldier | |
solicitor | |
solution | |
some | |
somebody | |
someone | |
something | |
sometimes | |
somewhat | |
somewhere | |
son | |
song | |
soon | |
sorry | |
sort | |
sound | |
source | |
south | |
southern | |
space | |
speak | |
speaker | |
special | |
species | |
specific | |
speech | |
speed | |
spend | |
spirit | |
sport | |
spot | |
spread | |
spring | |
staff | |
stage | |
stand | |
standard | |
staple | |
star | |
start | |
state | |
statement | |
station | |
status | |
stay | |
steal | |
step | |
stick | |
still | |
stock | |
stone | |
stop | |
store | |
story | |
straight | |
strange | |
strategy | |
street | |
strength | |
strike | |
strong | |
strongly | |
structure | |
student | |
studio | |
study | |
stuff | |
style | |
subject | |
substantial | |
succeed | |
success | |
successful | |
such | |
suddenly | |
suffer | |
sufficient | |
suggest | |
suggestion | |
suitable | |
sum | |
summer | |
sun | |
supply | |
support | |
suppose | |
sure | |
surely | |
surface | |
surprise | |
surround | |
survey | |
survive | |
switch | |
system | |
table | |
take | |
talk | |
tall | |
tape | |
target | |
task | |
tax | |
tea | |
teach | |
teacher | |
teaching | |
team | |
tear | |
technical | |
technique | |
technology | |
telephone | |
television | |
tell | |
temperature | |
tend | |
term | |
terms | |
terrible | |
test | |
text | |
than | |
thank | |
thanks | |
that | |
the | |
theatre | |
their | |
them | |
theme | |
themselves | |
then | |
theory | |
there | |
therefore | |
these | |
they | |
thin | |
thing | |
think | |
this | |
those | |
though | |
thought | |
threat | |
threaten | |
through | |
throughout | |
throw | |
thus | |
ticket | |
time | |
tiny | |
title | |
today | |
together | |
tomorrow | |
tone | |
tonight | |
too | |
tool | |
tooth | |
top | |
total | |
totally | |
touch | |
tour | |
towards | |
town | |
track | |
trade | |
tradition | |
traditional | |
traffic | |
train | |
training | |
transfer | |
transport | |
travel | |
treat | |
treatment | |
treaty | |
tree | |
trend | |
trial | |
trip | |
troop | |
trouble | |
true | |
trust | |
truth | |
try | |
turn | |
twice | |
type | |
typical | |
unable | |
under | |
understand | |
understanding | |
undertake | |
unemployment | |
unfortunately | |
union | |
unit | |
united | |
university | |
unless | |
unlikely | |
until | |
upon | |
upper | |
urban | |
use | |
used | |
useful | |
user | |
usual | |
usually | |
value | |
variation | |
variety | |
various | |
vary | |
vast | |
vehicle | |
version | |
very | |
via | |
victim | |
victory | |
video | |
view | |
village | |
violence | |
vision | |
visit | |
visitor | |
vital | |
voice | |
volume | |
vote | |
wage | |
wait | |
walk | |
wall | |
want | |
war | |
warm | |
warn | |
wash | |
watch | |
water | |
wave | |
way | |
weak | |
weapon | |
wear | |
weather | |
week | |
weekend | |
weight | |
welcome | |
welfare | |
well | |
west | |
western | |
what | |
whatever | |
when | |
where | |
whereas | |
whether | |
which | |
while | |
whilst | |
white | |
who | |
whole | |
whom | |
whose | |
why | |
wide | |
widely | |
wife | |
wild | |
will | |
win | |
wind | |
window | |
wine | |
wing | |
winner | |
winter | |
wish | |
with | |
withdraw | |
within | |
without | |
woman | |
wonder | |
wonderful | |
wood | |
word | |
work | |
worker | |
working | |
works | |
world | |
worry | |
worth | |
would | |
write | |
writer | |
writing | |
wrong | |
yard | |
yeah | |
year | |
yes | |
yesterday | |
yet | |
you | |
young | |
your | |
yourself | |
youth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment