The CreatorCon Call for Content is officially open! Get started here.

Alternatives to Javascript Library Forge in ServiceNow

Shanti7
Tera Contributor

We are trying to setup an integration with another application, but that application expecting the Payload in 'Salt and HMAC' values. 

They are currently using the Javascript library, 'Forge' to decrypt the payload and shared the following function to convert the payload into Salt and HMAC values. It appears the library, 'Forge' is not supported by ServiceNow, so wondering if we have any alternatives in ServiceNow which can help us convert the Paylod into Salt and HMAC values. 

 

Sample Code using Forge library: 

function makeStrMac(data, pass) {
var randomBytes = forge.random.getBytesSync(32);
var salt = forge.util.bytesToHex(randomBytes); // creates random salt value as hexadecimal text, 64 characters
var md = forge.md.sha256.create();
var derivedKey = forge.pkcs5.pbkdf2(pass, salt, rounds, 32, md); // stock key for hmac
var hmac = forge.hmac.create();
hmac.start('sha256', derivedKey);
hmac.update(data);
var hash = hmac.digest();
var hashText = hash.toHex(); // mac value as hexadecimal text, 64 characters
return salt + hashText;
}

0 REPLIES 0