# getSHA256

## `getSHA256` Function

The `getSHA256` function generates a **SHA-256 hash** from a given input string using Node.js’ built-in [`crypto`](https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options) module. It supports configurable **encoding formats** for output customization.

***

### Purpose

Use `this.getSHA256` to:

* Generate **secure, one-way hashes** of input values
* Anonymize sensitive data such as user IDs, IPs, or email addresses
* Create consistent, tamper-proof identifiers across systems

***

### Function Definition

| Property          | Description                          |
| ----------------- | ------------------------------------ |
| **Function Name** | `this.getSHA256`                     |
| **Type**          | `function`                           |
| **Available In**  | Server-Side Variables                |
| **Returns**       | `string` (SHA-256 hash of the input) |

***

### Parameters

| Parameter  | Description                                           | Type     | Required                                      | Example    |
| ---------- | ----------------------------------------------------- | -------- | --------------------------------------------- | ---------- |
| `input`    | The input string to hash                              | `string` | <i class="fa-square-check">:square-check:</i> | `"secret"` |
| `encoding` | Output format of the hash (e.g., `"hex"`, `"base64"`) | `string` | <i class="fa-square-check">:square-check:</i> | `"hex"`    |

***

### Supported Encodings

See the [Node.js crypto documentation](https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options) for full details.

Common options include:

* `hex` — Standard readable format (recommended)
* `base64` — Compact and URL-safe
* `latin1` — Raw binary encoding

***

### Example Usage

```js
async function() {
    let x = this.getSHA256("secret", "hex");
    return x;
}
```

In this example, the SHA-256 hash of the string `"secret"` is returned in hexadecimal format.

***

### Use Cases

* Anonymize personal data before storage or processing
* Create secure fingerprints for tracking without revealing raw input
* Validate content integrity across systems

***

### Notes

* SHA-256 is **cryptographically secure** and suitable for compliance-focused use cases (e.g. GDPR pseudonymization).
* Always explicitly provide the desired encoding.
* For custom algorithms or flexibility, consider using `this.getHash`.

***

### Summary

`this.getSHA256` is a secure and reliable way to hash data in JENTIS server-side variables. It’s the preferred function for anonymizing identifiers or generating hashed tokens when privacy and integrity matter.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jentis.com/developer-guide/variables/server-side-variables/public-function-scope/getsha256.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
