import string
import random


def key_generator(size=6, chars=string.ascii_uppercase + string.digits):
    """
        Generates random strings for things that need keys. Allows variable size and character lists, if desired.
        NOT CRYPTOGRAPHICALLY SECURE
    :param size: Size of the key to generate
    :param chars: Characters to choose from
    :return: Key composed of given characters with a given size, in random order
    """
    return ''.join(random.choice(chars) for _ in range(size))