NODE.JS sample code for the signature calculation

 

 

'use strict';

var crypto = require('crypto');

var sign = function(apiCmd, keyString) {
	var usablePrivateKey = keyString.replace(/[-]/g, '+').replace(/[_]/g, '/');
	var privateKeyBytes = new Buffer(usablePrivateKey, 'base64');
	var algorithm = crypto.createHmac('sha1', privateKeyBytes);
	var hash = algorithm.update(apiCmd).digest('base64');
	var signature = hash.replace(/[+]/g, '-').replace(/[/]/g, '_');

	return signature;
};

module.exports =  sign ;

console.log(sign("COMMAND_ITEM_TO_SIGN", "YOUR_PRIVATE_KEY"));
Terms Of Use | Privacy Statement | Company info
  • © Cedac Sistemi srl
  • Head office: Via Toscana, 3 40035 Castiglione dei Pepoli (Italy) Tel.: +39 0534-93811 Fax: +39 0534-93899
  • Branch office: Via del Lavoro, 47 40033 Casalecchio di Reno (Italy)
  • Branch office: Via Parini, 1 40033 Casalecchio di Reno (Italy)
  • Share capital Euro 26,000.00 - Company Register of Bologna / VAT no / fiscal code 01695261204