Pythonic Password Generator

Here’s a very easily developed password generator for Python.

>>> import string, random
>>> def passgen(length) :
... keys = list(string.ascii_letters + string.digits + ".,;:-_()@"\[]?!'^+*$%&/=~`<>|")
... return "".join(random.choice(keys) for i in range(length))
>>> passgen(15)
>>> passgen(6)
>>> passgen(16)
>>> passgen(25)

If you only want ascii and digits then it’s obvious what to do I guess?

Leave a Reply

Your email address will not be published. Required fields are marked *