We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Sign a request using NodeJS

I have been playing around trying to sign a request using nodeJS but it seems to be producing a different hash result when using the node crypto.createHmac. When using the the php hash_hmac it works perfectly I was just wondering if anybody as achieved making a successful request in node.

Hi Daniel,


Thanks for inquiring Aspose.

I have observed your inquiry and it seems related to Aspose cloud platforms. I am moving the request to Aspose.Total forum where by our respective team representative will help you better in this regard.

Many Thanks,

Hi Daniel,

Following code works at my end. Please give it a try and let us know if it works for you also.

var http = require('http');<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

var fs = require('fs');

var crypto = require('crypto')

, app_sid='77*****-****-****-****-***********'

, app_key = '89*****************'

, signature;

var url_to_sign = 'http://api.aspose.com/v1.1/words/Sample.doc?format=pdf&appSID='+app_sid;

var raw_signature = crypto.createHmac('sha1', app_key).update(url_to_sign.replace(/\s/g, '%20')).digest('base64');

signature = raw_signature.replace(/\//g, '%2F').replace(/=/g, '');

var signed_uri = url_to_sign.replace(/\s/g, '%20')+'&signature='+signature;

var file = fs.createWriteStream("Output.pdf");

var request = http.get(signed_uri, function(response) {

response.pipe(file);

});

console.log('Output file saved as Output.pdf');

Best Regards,