import random


def rand_hex_str(str_len:int = 2) -> str:
    """
    Random hex string of specified length

    Parameters
    ----------
    str_len : int
        Length of random hex string, default 2 (characters)
    
    Returns
    -------
    rand_str : str
        String with random hexadecimal characters
    """

    # IMPORT DONE HERE TO SAVE TIME AT MODULE INIT

    if str_len <= 0:
        raise ValueError('Invalid string length.')
    s = ''
    while str_len > 6:
        s += rand_hex_str(6)
        str_len -= 6
    s += ('{0:0' + str(str_len) + 'x}').format(random.randrange(16 ** str_len))
    return s