Generating Random strings using Python


Just wanted to share a very small implementation of generating random string values for a range of 6 chars, I am actually working on creating a hashing of the keys for some authentication module. I will share the same implementation soon for that Keep watching :).

Just for now have a look on this. Hope this helps some one out there.

import random
import string

def genearateRandomStrings():

//creates a combination of chars
chars=string.ascii_lowercase + string.ascii_uppercase

//now using the random module functions and list comprehension generate a set of random strings.
return ”.join(random.choice(chars) for x in range(6))

print genearateRandomStrings()


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.