getHash
getHash
Function
getHash
FunctionThe getHash
function generates a hashed string from a given input using the Node.js crypto
library. It supports configurable hashing algorithms and output encodings.
Purpose
Use this function to:
Create hashed versions of identifiers or tokens
Generate consistent anonymized values (e.g., hashed IPs, emails)
Integrate hash-based logic into tracking or enrichment flows
Function Definition
Function Name
this.getHash
Type
function
Available In
Server-Side Variables
Returns
string
(the hashed value of the input)
Parameters
input
The input string to be hashed
string
"secret"
algorithm
The hashing algorithm to use (e.g., "sha256"
, "md5"
, etc.)
string
"sha256"
encoding
The output format of the hash ("hex"
, "base64"
, etc.)
string
"hex"
Default Encoding:
"hex"
if not specified
Supported Algorithms & Encodings
See the official Node.js Crypto documentation for a full list of supported algorithms and encodings.
Common choices:
Algorithms:
sha256
,sha1
,md5
,sha512
Encodings:
hex
,base64
,latin1
Example Usage
async function() {
let x = this.getHash("secret", "sha256", "hex");
return x;
}
This example returns a SHA-256 hash of the string "secret"
encoded in hexadecimal.
Use Cases
Generate anonymized keys (e.g., hashed IP or user ID)
Create checksum or verification values
Store secure reference identifiers without exposing raw input
Match identifiers across systems using shared hashing rules
Notes
This function uses Node.js' built-in
crypto.createHash
behind the scenes.Output is deterministic: same input → same hash.
Make sure the chosen algorithm and encoding match your system requirements.
Do not use
md5
orsha1
for security-critical applications — these are considered weak.
Summary
this.getHash
is a flexible and secure way to generate hashed values in JENTIS server-side variables. Whether you’re anonymizing personal data or aligning IDs across systems, this function allows full control over the hashing algorithm and encoding.
Last updated
Was this helpful?