Skip to content

Instantly share code, notes, and snippets.

@23maverick23
Last active June 9, 2019 11:27
Show Gist options
  • Save 23maverick23/4131896 to your computer and use it in GitHub Desktop.
Save 23maverick23/4131896 to your computer and use it in GitHub Desktop.
Python: Random password generator
#!/usr/bin/env python
import string
import random
def password_generator(size=8, chars=string.ascii_letters + string.digits):
"""
Returns a string of random characters, useful in generating temporary
passwords for automated password resets.
size: default=8; override to provide smaller/larger passwords
chars: default=A-Za-z0-9; override to provide more/less diversity
Credit: Ignacio Vasquez-Abrams
Source: http://stackoverflow.com/a/2257449
"""
return ''.join(random.choice(chars) for i in range(size))
@Johnnysavior
Copy link

thanks, this is just what I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment