> For the complete documentation index, see [llms.txt](https://platformdocs.lattica.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platformdocs.lattica.ai/how-to-guides/secure-query-processing/how-to-encrypt-execute-and-decrypt-in-one-step.md).

# How-To: Encrypt, Execute, and Decrypt in One Step

LatticaAI provides a streamlined way to perform **end-to-end query execution** in a single command using our SDK. Instead of calling separate functions for encryption, query submission, and decryption, this method allows users to provide an input and receive the decrypted output in one step.

This functionality is available in both **Python** and **TypeScript SDKs**.

***

### **Prerequisites**

Before executing a complete query, ensure that:

1. **A valid User Access Token is available**, provided by the Provider for a specific workload.
2. **An Evaluation Key (EVK) is generated and published** to the LatticaAI backend.
   * See: \[How-To: [Upload Evaluation Key](/how-to-guides/secure-query-processing/how-to-upload-evaluation-key.md)]

***

### **Executing a Query in One Command**

Use the following code snippet to encrypt the input message. The encryption process takes the **User Access Token** and the **message to be encrypted** as parameters:

{% tabs %}
{% tab title="🧊Python SDK" %}

```python
import torch
import matplotlib.pyplot as plt
from lattica_query.lattica_query_client import QueryClient

# Authenticate
client = QueryClient("user_token_from_lattica_console")

# Generate keys and upload the evaluation key to the server.
(
    context,
    secret_key,
    client_blocks,
) = client.generate_key()


# Run multiple encrypted queries
image1 = plt.imread('image1.png')
pt1 = torch.Tensor(image1)
result1 = client.run_query(context, secret_key, pt1, client_blocks)

image2 = plt.imread('image2.png')
pt2 = torch.Tensor(image2)
result2 = client.run_query(context, secret_key, pt2, client_blocks)

```

{% endtab %}

{% tab title="📦TypeScript SDK" %}

```typescript
import { LatticaQueryClient, imageToTensor } from '@Lattica-ai/lattica-query-client';

// Authenticate
const client = new LatticaQueryClient("user_token_from_lattica_console");

// Generate keys and upload the evaluation key to the server.
await client.init();

// Run multiple encrypted queries
const pt1 = await imageToTensor(imageDataUrl1);
const res1 = await client.runQuery(pt1);

const pt2 = await imageToTensor(imageDataUrl2);
const res2 = await client.runQuery(pt2);
```

{% endtab %}
{% endtabs %}
