cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Mapper expression required for encoding

yash_verma
New Contributor

Hi Team,
Help required to implement below logic for one field in mapper snap. Please help
API_KEY =โ€œ3456789dgghhjhโ€
SECRET=โ€œ8889999456hhggth74kjuโ€
var payload = โ€˜POST\n\nโ€™ + date.toString() + โ€˜\nโ€™;
hmac = crypto.createHmac(โ€˜sha256โ€™, SECRET);
hmac.update(payload);
โ€˜Authorizationโ€™: 'INDIA โ€™ + API_KEY + โ€˜:โ€™ + hmac.digest(โ€˜base64โ€™),

Thanks

Yash

3 REPLIES 3

cjhoward18
Employee
Employee

@yash.verma

Not exactly sure what you want the final form to look like, but here is an expression that uses sha256

and Base64#encode

with your sample string to give something similar to what you are looking for I believe. Here is the expression I used given your example. I replaced the SECRET with the actual value and the date with Date.now():

Base64.encode('POST\n\n' + Date.now().toString() + '\n' + Digest.sha256("8889999456hhggth74kju"))

Hi ,

How to implement hmac cryptograhy in snaplogic. I need to call an rest api which uses hmac encrytion and the code snippet which I have given is required to be converted in same way in snaplogic to derive the mapper variable

jervin
New Contributor III

Hi @yash.verma did you ever find a solution for this?