Hi ,
I can understand that key should be 256 bit but as per client requirement we need to use keys as 7 digit like "TEIFHEW" , do we have an option to work this on datapower as same is working in other js compiler .
Regards ,
mayur
------------------------------
mayur gharat
------------------------------
Original Message:
Sent: Fri March 17, 2023 03:20 PM
From: Gabriel Marte Blanco
Subject: HMAC 256 Not working .
Hi Mayur,
it seems like the issue is that there is no padding for the key - you need to provide a 32 byte key. the folks here have used stuff like
var encryptionKey = crypto.randomBytes(32);
you could also potentially create a crypto key object on the device and point to a text like 0x123 for a 256 bit key then reference the name of the object in the script.
------------------------------
Gabriel Marte Blanco
Austin TX
Original Message:
Sent: Thu March 09, 2023 01:24 PM
From: mayur gharat
Subject: HMAC 256 Not working .
We have used below code for HMAC but getting error as 256 bit require in datap[ower
as per client requirement key should be "TEIFHEW" but same is working online js complier but on datapower not working .
const crypto = require('crypto');
const secret = Buffer.from('TEIFHEW');
// Calling createHmac method
const hash = crypto.createHmac('sha256', secret).update('mayur').digest('base64');
session.output.write(hash)
// Displays output
console.log(hash);
------------------------------
mayur gharat
------------------------------