# encrypt - Liquid Filter Reference

Source: https://support.storeconnect.com/articles/encrypt-filter-reference · Last modified 21 August 2026

## Description

Encrypts a value using symmetric encryption. The result can be decrypted using the [decrypt](decrypt-filter-reference) filter with the same `salt` value. Supports String, Integer, Float, Boolean, Array, and Hash types. Encryption errors are logged to the Web Console rather than surfaced to the storefront.

Use this filter to safely pass state between Liquid templates — for example, storing values in hidden form fields, passing data through URLs, or sharing data between Liquid components without exposing the raw value.

| Property | Value |
|----------|-------|
| **Return Type** | string |
| **Error return** | `nil` (not an empty string) |
| **Category** | text |

## Options

| Option | Description |
|--------|-------------|
| `salt` | An optional salt string used as part of the encryption key. Use the same `salt` value when decrypting. **If omitted, the current session ID is used as the salt — the token is session-bound and cannot be decrypted in a different session.** |

## Session-bound tokens

When `salt` is not provided, the token is encrypted using the current session ID as the implicit salt. This means:

- The encrypted value can **only be decrypted within the same session**
- If the same encrypted value is passed to a new session (for example, via a URL), decryption will fail
- Use an explicit `salt` value when you need to decrypt across requests or sessions (for example, storing values in a database or passing them via email links)

## Supported input types

The following input types can be encrypted and round-tripped through [decrypt](decrypt-filter-reference):

- String
- Integer
- Float
- Boolean (`true` / `false`)
- Array
- Hash

## Examples

**Encrypt a string:**


```liquid

{{ "sensitive data" | encrypt }}
```


**Encrypt with a salt:**


```liquid

{{ "sensitive data" | encrypt: salt: "my-secret-salt" }}
```


**Encrypt and immediately decrypt (round-trip):**


```liquid

{% assign encrypted = "hello" | encrypt: salt: "my-salt" %}
{{ encrypted | decrypt: salt: "my-salt" }}
```


**Output:** `hello`

## Error handling

If encryption fails, the error is written to the Web Console and `nil` is returned (not an empty string — check for nil before using the result). The specific error message depends on the cause:

| Cause | Console message |
|-------|----------------|
| No encryption salt configured | `No encryption salt found. Cannot encrypt or decrypt data.` |
| Unsupported input type | `Decrypted token has unsupported type {type}` |

Check the Web Console when troubleshooting missing or nil encrypted values.

---

## Follow StoreConnect

- [Email Newsletter](https://getstoreconnect.com/c/lp-newsletter)
- [LinkedIn Newsletter](https://www.linkedin.com/build-relation/newsletter-follow?entityUrn=7444956928444862464)
- [YouTube](https://www.youtube.com/channel/UCngKdP2x8l1wcbAKW3tvU8g)
- [LinkedIn](https://www.linkedin.com/company/storeconnect)
- [X / Twitter](https://x.com/storeconnecthq)

## Popular Links

- [Partners](https://getstoreconnect.com/partners)
- [News](https://getstoreconnect.com/articles/news)
- [Events](https://getstoreconnect.com/articles/events)
- [Feature Comparison](https://getstoreconnect.com/how-we-compare)
- [Download a free trial](https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FMkeKUAT)
- [Book a Demo](https://getstoreconnect.com/contact)

## Documentation

- [Help documentation](https://support.storeconnect.com/help-documentation)
- [AI agents](https://support.storeconnect.com/ai)
- [Videos & tutorials](https://support.storeconnect.com/videos-tutorials)
- [Developer reference](https://support.storeconnect.com/developer-reference)
- [Release notes](https://support.storeconnect.com/release-notes)
- [Troubleshooting](https://support.storeconnect.com/troubleshooting)
- [Trust Center](https://trust.getstoreconnect.com/)
- [Status Page](https://status.storeconnect.com/)

## Contact

- info@getstoreconnect.com
- US +1 415 745 3230
- AUS +61 2 8365 2308

100 S Ashley Dr, Suite 600-2461
Tampa FL 33602-600 USA

Level 22, Sydney Place
180 George Street
Sydney, NSW, 2000, AUS

---

StoreConnect Support — https://support.storeconnect.com/articles/encrypt-filter-reference