import random
import string


def str_rand_gen(size):
    """Returns an encoded random string of length 'size'."""
    msg = '\n'
    msg += "".join(random.choice(string.ascii_lowercase + string.digits) for _ in range(size-1))
    return msg.encode('ascii', 'replace')