getSHA256

getSHA256 Function

The getSHA256 function generates a SHA-256 hash from a given input string using Node.js’ built-in crypto 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

"secret"

encoding

Output format of the hash (e.g., "hex", "base64")

string

"hex"


Supported Encodings

See the Node.js crypto documentation for full details.

Common options include:

  • hex — Standard readable format (recommended)

  • base64 — Compact and URL-safe

  • latin1 — Raw binary encoding


Example Usage

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.

Last updated

Was this helpful?