Skip to content

Instantly share code, notes, and snippets.

@Jacajack
Created February 28, 2016 17:16
Show Gist options
  • Save Jacajack/fea8847fd7469e059b43 to your computer and use it in GitHub Desktop.
Save Jacajack/fea8847fd7469e059b43 to your computer and use it in GitHub Desktop.
Python dictionary password generator (like correct horse battery staple)
#!/usr/bin/python
import random;
import sys;
Words = [Word.rstrip( '\n' ) for Word in open( "/usr/share/dict/american-english") ];
Length = raw_input( "How many words should Your xkcd like password have? " );
try:
Length = int( Length );
except:
print( "Please enter a valid integer number!" );
Length = 0;
Password = "";
for i in range( Length ):
Password += ( '\x1b[3' + str( 1 + i % 7 ) + ';1m' );
Password += ( Words[random.randrange(0, len( Words ) ) ] );
print( Password );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment