---
title: AES_ENCRYPT
url: https://www.tines.com/docs/formulas/functions/aes-encrypt/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# AES_ENCRYPT

*[View on tines.com](https://www.tines.com/docs/formulas/functions/aes-encrypt/)*

Note: AES_ENCRYPT and AES_DECRYPT are now deprecated. Please use either TINES_ENCRYPT/TINES_DECRYPT or OPENSSL_ENCRYPT/OPENSSL_DECRYPT instead.

Encrypts text using AES

The output is encoded with character set "[A-Za-z0-9+/=\.]" (base64 + '.').

`AES_ENCRYPT(text, key, [iv], [mode: "aead"], [expires_in])`

text: The plaintext to be encrypted.

key: A 32 byte secret value to be used for encryption.

iv: A 16 byte value that must never be repeated. Note that when the "mode" is set to "aead" the iv is managed and does not need to be set.

mode: Determines how AES_ENCRYPT should behave, with the default mode being a very plain aes-256-cbc implementation and "aead" being an authenticated encryption mode designed to be safer and easier to use.

expires_in: An integer that defines the number of seconds before the ciphertext will be rejected by AES_DECRYPT, this is only available when the mode is set to "aead" and the expiration is enforced by AES_DECRYPT.

**Categories:** Encryption

## Syntax

```
AES_ENCRYPT(text, key, [iv], [mode: "aead"], [expires_in])
```

## Examples

### Example 1

Formula:

```
AES_ENCRYPT("hello world", CREDENTIAL.secret_key, mode: "aead", expires_in: 60)
```

## Sample actions

### Sample action 1

```json
{
  "standardLibVersion": "65",
  "actionRuntimeVersion": "2",
  "agents": [
    {
      "disabled": false,
      "name": "AES_ENCRYPT",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "aes_encrypt": "=AES_ENCRYPT(my_action.message, CREDENTIAL.aes_secret_key, CREDENTIAL.aes_iv, mode:\"aead\")"
        }
      },
      "position": {
        "x": 1620,
        "y": 1830
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "message": "This is a private message for your eyes only!"
        }
      },
      "position": {
        "x": 1725,
        "y": 1740
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "AES_ENCRYPT",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "aes_encrypt": "=AES_ENCRYPT(my_action.message, CREDENTIAL.aes_secret_key, mode: \"aead\")"
        }
      },
      "position": {
        "x": 1800,
        "y": 1830
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 0
    },
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 2
    }
  ],
  "diagramNotes": []
}
```

### Sample action 2

```json
{
  "standardLibVersion": "66",
  "actionRuntimeVersion": "2",
  "agents": [
    {
      "disabled": false,
      "name": "AES_ENCRYPT",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "aes_encrypt": "=AES_ENCRYPT(my_action.message, CREDENTIAL.aes_secret_key, CREDENTIAL.aes_iv, mode:\"aead\", expires_in: 60)"
        }
      },
      "position": {
        "x": 1620,
        "y": 1830
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "message": "This is a private message for your eyes only!"
        }
      },
      "position": {
        "x": 1725,
        "y": 1740
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "AES_ENCRYPT",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "aes_encrypt": "=AES_ENCRYPT(my_action.message, CREDENTIAL.aes_secret_key, mode: \"aead\")"
        }
      },
      "position": {
        "x": 1800,
        "y": 1830
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 0
    },
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 2
    }
  ],
  "diagramNotes": []
}
```

### Sample action 3

```json
{
  "standardLibVersion": "13",
  "actionRuntimeVersion": "2",
  "agents": [
    {
      "disabled": false,
      "name": "AES_ENCRYPT",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "aes_encrypt": "=AES_ENCRYPT(my_action.message, CREDENTIAL.aes_secret_key, CREDENTIAL.aes_iv)"
        }
      },
      "position": {
        "x": 1620,
        "y": 1830
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "message": "This is a private message for your eyes only!"
        }
      },
      "position": {
        "x": 1725,
        "y": 1740
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "AES_ENCRYPT",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "aes_encrypt": "=AES_ENCRYPT(my_action.message, CREDENTIAL.aes_secret_key, mode: \"aead\")"
        }
      },
      "position": {
        "x": 1800,
        "y": 1830
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 0
    },
    {
      "sourceIdentifier": 1,
      "receiverIdentifier": 2
    }
  ],
  "diagramNotes": []
}
```
