---
title: "ezgh keys encrypt"
description: "Encrypt up to 4 KiB, from stdin or a file."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh keys encrypt

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh keys encrypt <key> [--file path] [--context key=value]... [flags]
```

Encrypt up to 4 KiB under a key, read from stdin or `--file`, never from an argument. The ciphertext is printed alone; -o json adds the key's ID. For more than 4 KiB, use `ezgh keys generate-data-key`.

Part of [`ezgh keys`](/cli/reference/keys).

## Examples

```sh
ezgh keys encrypt alias:orders --context tenant=acme < token.txt > token.enc
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--context` | string, repeatable |  | encryption context; opening it needs the same one, key=value; repeat for more |
| `--context-file` | string |  | encryption context; opening it needs the same one, from a file holding a JSON object of strings |
| `--file` | string |  | read the plaintext from this file instead of stdin |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/keys-encrypt/index.mdx
