Skip to content

Instantly share code, notes, and snippets.

@archerslaw
Forked from guixing/pwgen.py
Created September 28, 2013 04:09
Show Gist options
  • Save archerslaw/6738280 to your computer and use it in GitHub Desktop.
Save archerslaw/6738280 to your computer and use it in GitHub Desktop.
import random
import string
smailar_chars = '01oilLIOpP'
upper = "".join(set(string.uppercase) - set(smailar_chars))
lower = "".join(set(string.lowercase) - set(smailar_chars))
chars = upper + lower
numbers = '23456789'
symbols = '#$%&+,-./:;_~?=@!'
groups = (upper, lower, numbers, symbols)
def genpass(length=8):
pw = [random.choice(i) for i in groups]
print pw
con = ''.join(groups)
for i in range(length-len(pw)):
pw.append(random.choice(con))
random.shuffle(pw)
return ''.join(pw)
import sys
print genpass(int(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment