]> code.delx.au - monosys/commitdiff
Made passwdgen cooler
authorJames Bunton <jamesbunton@fastmail.fm>
Mon, 13 Aug 2007 02:16:16 +0000 (12:16 +1000)
committerJames Bunton <jamesbunton@fastmail.fm>
Mon, 13 Aug 2007 02:16:16 +0000 (12:16 +1000)
scripts/passwdgen

index 04302e846f3a433294c822d4e1769a65586fdc7c..7d1556bbaf4b716be5b870d8b6a73871214f5093 100755 (executable)
@@ -2,14 +2,9 @@
 
 import random, string, sys
 
+chars = filter(lambda x: not x.isspace(), string.printable)
 def generate(length):
-       passwd = ""
-       for i in xrange(length):
-               c = random.choice(string.printable)
-               while c.isspace():
-                       c = random.choice(string.printable)
-               passwd += c
-       return passwd
+       return "".join([random.choice(chars) for i in xrange(length)])
 
 if __name__ == "__main__":
        try: