import string
import random


def gen_random_string(length_of_str):
    """generate a string containing random characters of length length_of_str
    """
    source_set = string.ascii_letters+string.digits+string.punctuation
    result=[]
    for x in range(length_of_str):
        result.append(random.choice(source_set))
    return ''.join(result).encode('us-ascii')