How to Generate Hash
Updated
The hash is a Hash-based Message Authentication Code (HMAC). Sprinklr uses the SHA 256 hash function to generate HMAC.
Let’s take an example of the following user:
user: {
userId: '12345',
firstName: 'John',
lastName: 'Doe',
phoneNo: '9876543210',
email: 'John.Doe@example.com',
profileImageUrl: 'https://example.com/profilePic.jpg',
hash: 'f30c3b0835ecd378a134c74bce8cea866df8c5b6e12a8c219c9bb288f7270e22'
}
Follow these steps to generate a hash for the example user:
1. Concatenate specific user details in the following order, separating each with an underscore (_) to create a string:
userId_firstName_lastName_profileImageUrl_phoneNo_email
For example, the resulting string to generate the hash would be:
12345_John_Doe_https://example.com/profilePic.jpg_9876543210_John.Doe@example.com
2. Pass the string and API key provided by Sprinklr to the following JavaScript function:
import crypto from 'crypto-js';
const getHMACHash = (message, key) => crypto.HmacSHA256(message, key).toString(); //API Key will be provided by Sprinklr
Sample code to generate HMAC is mentioned in Sample code for hash generation.
Note: Ensure you have the required dependency installed, and the version must be within the specified range:
"crypto-js": "<= 3.3.0"
For more information, refer to crypto-js documentation.