def decode(pem):
    try:
        pem = pem.encode('ascii', 'ignore')
    except AttributeError:
        pass
    if (b'PUBLIC KEY' in pem):
        return serialization.load_pem_public_key(pem, backend=default_backend())
    else:
        return serialization.load_pem_private_key(pem, password=None, backend=default_backend())
def decode(pem):
    try:
        pem = pem.encode('ascii', 'ignore')
    except AttributeError:
        pass
    if (b'PUBLIC KEY' in pem):
        return serialization.load_pem_public_key(pem, backend=default_backend())
    else:
        return serialization.load_pem_private_key(pem, password=None, backend=default_backend())