When calling Hmac functions in this library, I get the following stack trace:
TypeError: undefined is not a function
at Object.C_algo.HMAC.Base.extend.init (<path>/node_modules/crypto-js/hmac.js:58:18)
at Object.HmacSHA512 (<path>/node_modules/crypto-js/core.js:726:25)
<rest of stack trace is my app>
I tried HmacSHA512
and HmacSHA1
, using the example provided in the README. Both threw this error. At line 58 in hmac.js, the method 'clamp' is called on key: key.clamp()
. It appears this is the undefined function referenced in the stack trace. I'm not sure what this should be replaced with. This is the relevant code in my application:
const crypto = require('crypto-js');
const key = crypto.HmacSHA512(key, secret);
const crypto = require('crypto-js');
const key = crypto.HmacSHA512("Message", "Key").toString();
console.log(key)
Outputs
6b7c693d28c311b510c42bb30b07a61e9eb8d21918f257105fe65f1d82df6ac9c9abf0f282c20d646fc2f5015efbe473ac79afd67c756056f60a626afd58795d
For me, running crypto-js 3.1.5
, npm 2.9.1
& node 0.12.3
..
afaik clamp
is defined at core.js:247 || crypto.js:247
and should not return undefined unless they are missing. Double check your install, sounds like a weird error.