Created
May 15, 2015 23:34
-
-
Save CodyKochmann/997f997b0fcc33bb3693 to your computer and use it in GitHub Desktop.
Generates a random string with selectable characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def random_string(length=32,upper=True,lower=True,digits=True): | |
# Generates a random string with selectable characters | |
# By: Cody Kochmann | |
from random import choice | |
chars = "" | |
if upper: | |
chars+="QWERTYUIOPASDFGHJKLZXCVBNM" | |
if lower: | |
chars+="qwertyuiopasdfghjklzxcvbnm" | |
if digits: | |
chars+="1234567890" | |
return(''.join(choice(chars) for _ in range(length))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if upper:
chars += string.ascii_uppercase
if lower:
chars += string.ascii_lowercase
if digits:
chars += string.digits