Skip to content

password generator

python

xkcd style:

python -c 'import secrets;import string;f=open("/usr/share/dict/words");words=[word.strip().title() for word in f];digits=string.digits;password = "-".join(secrets.choice(words) for i in range(4)) + "_" + "".join(secrets.choice(digits) for i in range(3));print(password)'

random:

python -c 'import secrets;print(secrets.token_hex(32))'

if you want to pipe this into something like pbcopy to have it directly in your clipboard, do something like this to avoid a newline:

echo -n $(python -c 'import secrets;import string;f=open("/usr/share/dict/words");words=[word.strip().title() for word in f];digits=string.digits;password = "-".join(secrets.choice(words) for i in range(4)) + "_" + "".join(secrets.choice(digits) for i in range(3));print(password)') | pbcopy

you might want to check the official python docs.

others

  • pwgen