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:
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