Node Hmacsha1 Seed
I'm trying to send a SOAP request via Node, talking to a service which is secured with WSS. I need to sign the XML response with a SignedInfo element which requires me combining a
Solution 1:
I managed to get there in the end, there's an NPM module called psha1
(https://www.npmjs.com/package/psha1).
Using that library I created the following a generateSignature module which looks as follows:
const crypto = require('crypto');
const psha1 = require('psha1');
exportconstgenerateSignatureValue = ({
clientSecret,
serverSecret,
messageToSign,
}) => {
const secretKey =
psha1(clientSecret, serverSecret, 256);
const hash =
crypto
.createHmac('sha1', Buffer.from(secretKey, 'base64'))
.update(messageToSign)
.digest('binary');
returnBuffer
.from(hash, 'binary')
.toString('base64');
};
exportdefault generateSignatureValue;
This gives me the desired output :)
Post a Comment for "Node Hmacsha1 Seed"