Created
April 20, 2015 20:49
-
-
Save brent-hoover/d4d359d768063558c7f3 to your computer and use it in GitHub Desktop.
Create random characters for password
This file contains hidden or 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
import random | |
def _create_random_password(num_chars): | |
""" | |
Create a string of random characters | |
:param num_chars: | |
:return: | |
""" | |
password_string = '' | |
seed = string.ascii_letters + string.digits + string.punctuation | |
seed_len = len(seed) - 1 | |
for x in range(0, num_chars): | |
rnd = int(random.uniform(0, seed_len)) | |
random_char = seed[rnd:rnd+1] | |
password_string += random_char | |
return password_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment