def METHOD_NAME(key):
    # If it's an existing path: open() & read()
    if os.path.exists(os.path.expanduser(key)):
        with open(os.path.expanduser(key), "rb") as f:
            key = f.read() # b64encode(f.read())
    # If that seems like hexa, decode
    if isinstance(key, str) and re.match(r'^[0-9a-f]+$', key, re.IGNORECASE):
        key = binascii.unhexlify(key)
    # if, otherwise, that sounds like base64, decode
    elif isinstance(key, str) and re.match(r'^[a-z0-9/\+\.]+$', key, re.IGNORECASE):
        key = base64.b64decode(key)
    return key