Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # author: Brandon W Maister
- # This file is in the public domain
- """Create passwords using random words
- Long passwords are better than short, a long (20+ char) password made of
- whole words is better than a short one, unless the attacker knows that you're
- using whole words.
- This is good enough for me.
- """
- import sys
- try:
- from random import SystemRandom
- random = SystemRandom()
- except ImportError:
- print 'weak random numbers'
- import random
- def makepass(min_len=20):
- with open('/usr/share/dict/words') as fh:
- words = fh.readlines()
- password = ''
- while len(password) < min_len:
- password += random.choice(words).lower().strip() + ' '
- return password.strip()
- if __name__ == '__main__':
- if len(sys.argv) > 1:
- try:
- print makepass(int(sys.argv[1]))
- except ValueError:
- print "Only argument is the minimum length for the password"
- else:
- print makepass()
Add Comment
Please, Sign In to add comment