Trying to get the digest using crypto.hmac(sha256,API_Key) process and then to update a text to the hmac
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2019 09:33 PM
I am trying to get a digest in Hex format in ServiceNow as the requirement is to get the authentication code using the below Node.JS script-
//computing signature
const crypto = require('crypto');
const hmac = crypto.createHmac('sha256', API_KEY);
hmac.update("Error String"); // hash the form text to provide authentication
const digest = hmac.digest('hex');
console.log(digest);
I have used the below method to get the digest-
var mac = new GlideCertificateEncryption;
var key="API_KEY";
key = GlideStringUtil.base64Encode(key);
var text=mac.generateMac(key, "HmacSHA256", "Error String");
var digest = new GlideDigest();
gs.print(digest.getSHA256Hex(text));
It's giving me an incorrect output. Could anybody suggest me the right way to obtain the digest ?
Thanks in advance,
Manoj Kumar.
- Labels:
-
Integrations
-
Scripting and Coding
- 1,892 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2020 01:28 AM
Have you managed to get a solution for this? Looking for same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 10:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2020 03:21 PM
Did you find a solution for this? I have same requirements for an authentication HTTP header for a REST call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 10:44 AM