Differences in Node.js hash_hmac platform (Mac vs Ubuntu)

I was wondering what might affect the difference in hash computation between Mac (x64) and Ubuntu (32 bit). Start at the beginning:

Hashes generated on Ubuntu:

var string = "123";
// '123'
var hashKey = "abc";
// 'abc'
crypto.createHmac('sha512', hashKey).update(string).digest('hex')
// '1bb47a2e086bfab3a86e3843ffd665fead90f0ef46cf2894c56a194fb18158685e9fd364bde008d5f2cb04e649c7396adda38dc5617a9dd56ab981920ae13188'
crypto.createHmac('sha1', hashKey).update(string).digest('hex')
// 'be9106a650ede01f4a31fde2381d06f5fb73e612'

      

Hashes generated on macOS:

var string = "123";
// "123"
var hashKey = "abc";
// "abc"
crypto.createHmac('sha512', hashKey).update(string).digest('hex');
// "290f6f3488e8f8a62bdd91fcf7a255158e5034822667819d83fd2e77ece9e3edf44899aaf23cb1faf33826cdcc2724ac8c37e279d7133b01ecf9ba4b54f529e4"
crypto.createHmac('sha1', hashKey).update(string).digest('hex');
// "2d3aacdfbadf59cf8fb6b27bf576fcd783b8996c"

      

And as you can see, hashing the same values ​​gives us different results depending on the platform :( And it doesn't depend on the hash method (as in the example)

One suggestion I found is to take care of line endings, but ... no line endings in my case (password hashing - yes! I know I have to use bcrypt, but that's quite a lot for now migrating users).

Any other ideas / suggestions?

+3


source to share





All Articles