<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tokhex(length=10, urlsafe=False):
 """ Return a random string in hexadecimal """

    if urlsafe is True:
        return secrets.token_urlsafe(length)
    return secrets.token_hex(length)