Authentication in node.js

Archived from the Transloadit support forum. Originally posted on September 23, 2011; details may be outdated, see our docs for current behavior. Original thread

I am trying to get the Ruby sample given at http://transloadit.com/docs/authentication working in node.js. Could you please provide an equivalent node.js sample on that page?

I am a novice in using Crypto library. The signature from Ruby and node.js code are different. Any help is appreciated.

Ruby code:
require ‘openssl’
digest = OpenSSL::Digest::Digest.new(‘sha1’)
signature = OpenSSL::HMAC.hexdigest(digest, ‘auth secret’, ‘some string’)
puts signature

Node.js code:

var crypto, signature;
crypto = require('crypto');
signature = crypto.createHash("sha1").
        update('auth secret').
        update('some string').
        digest("hex")

console.log(signature);

Here is the solution that I got from nodejs Google group. Just use createHmac instead of createHash function.

var crypto, signature;
crypto = require('crypto');
signature = crypto.createHmac("sha1", 'auth secret').
        update('some string').
        digest("hex")
console.log(signature);

Thanks Rai. I understand that we can close this issue?

Yes the issue is resolved. Please go ahead and close it.

Regards,
Rafi