> For the complete documentation index, see [llms.txt](https://docs.skyone.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.skyone.cloud/espanol/skyone-studio/how-to/criptografia-funciones-de-hash-en-jsonata-usdmd5-y-usdsha256.md).

# Criptografía: Funciones de Hash en JSONata ($md5 y $sha256)

JSONata ofrece funciones de hash criptográfico que permiten transformar valores en representaciones únicas y determinísticas.

Estas funciones pueden usarse para:

* Garantizar la integridad de los datos
* Crear identificadores únicos
* Anonimizar valores sensibles
* Asegurar compatibilidad con sistemas externos

**Funciones soportadas:**

* `$md5(value)`
* `$sha256(value, digestFormat?)`

**Diferencia entre MD5 y SHA-256**

| Algoritmo | Tamaño del Hash          | Seguridad                       | Uso Común                               |
| --------- | ------------------------ | ------------------------------- | --------------------------------------- |
| MD5       | 32 caracteres (128 bits) | Débil, susceptible a colisiones | Checksums, validación simple            |
| SHA-256   | 64 caracteres (256 bits) | Fuerte, recomendado             | Autenticación, blockchain, criptografía |

#### Función `$md5(value)`

* Calcula el hash MD5 del valor proporcionado.
* **Retorno:** cadena hexadecimal fija de 32 caracteres.
* No posee parámetro de *digest*.

**Entrada:**

```json
Entrada:
{ "status": "200" }

Expresión: 
$md5(status)
```

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FU5Oi5HJauNyWCe5PIkj1%2Fimage%20-%202025-10-29T145233.153.png?alt=media&amp;token=22de2f51-9731-476f-8e5b-530f6a59360d" alt=""><figcaption></figcaption></figure>

```json
Salida:
{ "data": "3644a684f98ea8fe223c713b77189a77" }
```

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FJG9QRR9XfSx68Zdc1HRh%2Fimage%20-%202025-10-29T145240.627.png?alt=media&amp;token=84feec8b-3679-4d80-8041-641654c09452" alt=""><figcaption></figcaption></figure>

#### Función `$sha256(value, digestFormat?)`

* Calcula el hash SHA-256 del valor proporcionado.
* **Retorno:** cadena fija de 64 caracteres en hexadecimal (por defecto).
* Admite el parámetro `digestFormat` para cambiar el formato de la salida.

***

**Formatos soportados (`digestFormat`)**

| Valor                 | Descripción                    | Ejemplo de salida          |
| --------------------- | ------------------------------ | -------------------------- |
| `"hex"` (por defecto) | Representación hexadecimal     | `27badc983df1780b60c2...`  |
| `"base64"`            | Base64 estándar                | `J7cmD3xeAtgwrP6nToZoA...` |
| `"base64url"`         | Base64 adaptado para URLs/JWTs | `J7cmD3xeAtgwrP6nToZoA...` |

***

#### Ejemplos prácticos

SHA-256 en hex (default):

```json
Entrada: 
{ "status": "200" }

Expresión:
$sha256(status)
```

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FHKgJkbT8NCMpxReZY4fJ%2Fimage%20-%202025-10-29T145247.127.png?alt=media&amp;token=91ec192c-0dde-430b-ba83-24cc6ba0b17c" alt=""><figcaption></figcaption></figure>

**Salida:**

```json
{ "data": "27badc983df1780b60c2b3fa9d3a19a00e46aac798451f0febdca52920faaddf" }
```

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FYIpfuEDbdufc7pNA7zUM%2Fimage%20-%202025-10-29T145254.239.png?alt=media&amp;token=8a2aed93-3bb4-4385-b1cb-c325fd0dc594" alt=""><figcaption></figcaption></figure>

#### SHA-256 en Base64

**Entrada:**

<pre class="language-json"><code class="lang-json"><strong>Entrada: 
</strong><strong>{ "status": "200" }
</strong><strong>
</strong><strong>Expresión:
</strong>$sha256(status, "base64")
</code></pre>

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FqUaXokIRhbXApba4HnSK%2Fimage%20-%202025-10-29T145300.046.avif?alt=media&amp;token=46fd3ba8-06d6-4d7d-aac0-e4155ab1ccb1" alt=""><figcaption></figcaption></figure>

**Salida:**

```json
{ "data": "J7cmD3xeAtgwrP6nToZoA5GqseYRR8P69y1KSD6rd8=" }
```

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FCIfaTQ8bT0c5gxRVOYCH%2Fimage%20-%202025-10-29T145304.976.avif?alt=media&amp;token=832b57ce-f51b-4be2-b9e1-4252bb743a0a" alt=""><figcaption></figcaption></figure>

#### SHA-256 en JSON complejo (hex)

<pre class="language-json"><code class="lang-json">Entrada:
<strong>{ "response": "{...objeto JSON...}" }
</strong><strong>
</strong>Expresión:
$sha256(response)
</code></pre>

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FIfAk45hSGXZsBJ4Gs0dk%2Fimage%20-%202025-10-29T145304.976.avif?alt=media&amp;token=25b273af-77b7-4ae9-8789-f23aa6858194" alt=""><figcaption></figcaption></figure>

**Salida:**

```json
{ "data": "885826bd782b9b92cca593385729cc17ea05ca3f8f68935c5a1613102dfc066" }
```

<figure><img src="https://3969362974-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZB1uWLMGztphXAzIZJ1%2Fuploads%2FfKArXxJnrvQ6Frc9czje%2Fimage%20-%202025-10-29T145322.753.png?alt=media&amp;token=2eaf1489-7dfa-494f-b3af-e9f058925802" alt=""><figcaption></figcaption></figure>

#### Resumen de los tipos de digest

| Formato de digest | Descripción                              |
| ----------------- | ---------------------------------------- |
| hex               | Representación hexadecimal (por defecto) |
| base64            | Representación estándar en Base64        |
| base64url         | Base64 adaptado para URLs/JWTs           |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.skyone.cloud/espanol/skyone-studio/how-to/criptografia-funciones-de-hash-en-jsonata-usdmd5-y-usdsha256.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
