An open API service indexing awesome lists of open source software.

https://github.com/evervault/template-python-hello-function

Evervault template Hello World Function for Python.
https://github.com/evervault/template-python-hello-function

Last synced: 12 months ago
JSON representation

Evervault template Hello World Function for Python.

Awesome Lists containing this project

README

          

# Hello Function
[Evervault](https://evervault.com) makes it easy to encrypt data at source, process it in a Cage — a secure, serverless function — and never store it unencrypted.

This is a simple Evervault Function example, to help get you up and running on the Evervault platform quickly.

## Getting started with Evervault

Evervault consists of two parts, encrypting your data at source, using either our any of our SDKs and then sending that encrypted data to a Function to be processed securely.

This Function takes a payload that should contain a `name` key. Running the Function is very simple.

## The steps
1. Encrypt your data at source, using one of our SDKs.
2. Process the encrypted data in a Function

### Encrypting at source
```python
# This example uses the Evervault Python SDK.
import evervault

# Initialize the client with your app's API key
evervault.init("")

# Encrypt your data
encrypted = evervault.encrypt({ "name": "Claude" })
```

### Process your encrypted data in a Function
You should encrypt this payload using any SDKs, then run it in the Hello Function:

```python
# Process the encrypted data in a Function
result = evervault.run("", encrypted)
```

## Understanding the Function
This Function is very simple. Here is the full code:

```python
def handler(data):
if (data["name"] and isinstance(data["name"], str)):
print(f'A name of length {len(data["name"])} has arrived into the Function.');

return {
"message": f'Hello from a Function! It seems you have {len(data["name"])} letters in your name',
"name": f'{context["encrypt"](data["name"])}',
}
else:
print('An empty name has arrived into the Function.');

return {
"message": 'Hello from a Function! Send an encrypted `name` parameter to show Function decryption in action',
}
```

Or check it out in [main.py](./main.py).

---
If you want to know more about Evervault, check out our [documentation](https://docs.evervault.com).