Re: [nodejs] How to make node.js HMac sha1 with salt work with microsoft sha1?

256 views
Skip to first unread message

Dominic Tarr

unread,
Sep 6, 2012, 10:41:58 AM9/6/12
to nod...@googlegroups.com
maybe the microsoft version is using a different initialization vector?

On Mon, Sep 3, 2012 at 10:01 PM, kenny <kien....@gmail.com> wrote:
> Hi All,
>
> I have to work with microsoft database and using node.js, but I cannot make
> the hash value of the generated node.js to be the same as the one in the
> microsoft sql database?
>
> Is there anyways to do it?
>
> Also is there any library that can generate the same hash value?
>
> My company want to have the main website using microsoft C# and using
> node.js as the server side for mobile app?
>
> thank you all
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Ken

unread,
Sep 7, 2012, 6:00:57 PM9/7/12
to nod...@googlegroups.com
It's probably due to the subtleties of how SQL Server interacts with datatypes and not node per se--see the following for some details:

http://weblogs.sqlteam.com/mladenp/archive/2009/04/28/Comparing-SQL-Server-HASHBYTES-function-and-.Net-hashing.aspx

If you can't change the database side of this you may be able to reproduce SQL Server's behavior by mimicking it's byte-encoding before generating the hash.

JohnLeo Zimmer

unread,
Sep 7, 2012, 6:08:24 PM9/7/12
to nod...@googlegroups.com
CrLf issues sometimes get overlooked.

Scott Parmley

unread,
Mar 28, 2014, 1:13:03 PM3/28/14
to nod...@googlegroups.com
Don't know if you'll find this helpful at all but I was having the same problems.  I'm using JSON.net in my C# client and found that the ToString() method was returning a formatted JSON string that is different from what JSON.stringify returns.  I changed the resulting C# string to match exactly what JSON.stringify does and now HMAC+SHA1 works great between the two.





On Monday, September 3, 2012 2:01:02 PM UTC-6, kenny wrote:
Hi All,

I have to work with microsoft database and using node.js, but I cannot make the hash value of the generated node.js to be the same as the one in the microsoft sql database?

Reply all
Reply to author
Forward
0 new messages