Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'sigBytes' of undefined #85

Open
budingts opened this issue Feb 22, 2017 · 26 comments
Open

Cannot read property 'sigBytes' of undefined #85

budingts opened this issue Feb 22, 2017 · 26 comments

Comments

@budingts
Copy link

Cannot read property 'sigBytes' of undefined

TypeError: Cannot read property 'sigBytes' of undefined
at Object.init (/Volumes/T3/node_web/myapp/node_modules/crypto-js/hmac.js:53:21)
at /Volumes/T3/node_web/myapp/node_modules/crypto-js/core.js:744:25
at /Volumes/T3/node_web/myapp/routes/index.js:38:16
at Layer.handle [as handle_request] (/Volumes/T3/node_web/myapp/node_modules/express/lib/router/layer.js:95:5)
at next (/Volumes/T3/node_web/myapp/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Volumes/T3/node_web/myapp/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Volumes/T3/node_web/myapp/node_modules/express/lib/router/layer.js:95:5)
at /Volumes/T3/node_web/myapp/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Volumes/T3/node_web/myapp/node_modules/express/lib/router/index.js:330:12)
at next (/Volumes/T3/node_web/myapp/node_modules/express/lib/router/index.js:271:10)

@FernandoZX
Copy link

i have the same error

@ghost
Copy link

ghost commented Nov 10, 2017

any luck with this ? i have the same behavior

@ghost
Copy link

ghost commented Dec 9, 2017

same issue

@jackson-sandland
Copy link

same issue as well

@dmlzj
Copy link

dmlzj commented Dec 25, 2017

me too

@dmlzj
Copy link

dmlzj commented Dec 25, 2017

The parameter is wrong. It should be two, passed one

@alokshakya
Copy link

I also had the same error.
ERROR TypeError: Cannot read property 'sigBytes' of undefined
at new init (crypto-js.js:1913)
at Object.HmacSHA256 (crypto-js.js:744)
Later I put alert on parameters then found that one parameter is undefined. Please check parameters.

@Pentium286
Copy link

TypeError: Cannot read property 'sigBytes' of null

@prashanthbachu
Copy link

Same issue. It works in one environment and doesn't on other..any luck ?

@vghetau
Copy link

vghetau commented Apr 18, 2019

took me a while to figure this out. HmacSHA256 is not receiving all parameters, or receives "undefined".

@jayzhou3
Copy link

jayzhou3 commented Oct 8, 2019

I am getting this same issue and no one can fix the problem.

                            ^

TypeError: Cannot read property 'sigBytes' of undefined
    at new init (/Users/jay/homework/cryptoTest/node_modules/crypto-js/hmac.js:53:22)
    at Object.HmacSHA256 (/Users/jay/homework/cryptoTest/node_modules/crypto-js/core.js:744:25)
    at Object.<anonymous> (/Users/jay/homework/cryptoTest/index.js:5:29)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)

anyone has any idea how to fix it ??

@mwanchap
Copy link

mwanchap commented Oct 24, 2019

I had the same issue - big thanks to @vghetau for pointing me in the right direction! This error means that one of the hmac crypto functions is receiving an undefined value in the "key" parameter (which is the second one). I found it by doing some logging to see which was undefined:

console.log(signature); // prints the expected signature
console.log(secret); // prints "undefined"!
signature = CryptoJS.HmacSHA256(signature, secret);

From there it was straightforward to trace that variable back and see that it was being assigned incorrectly. If you're getting this error from some other code that's ending up in a call to CryptoJS, you might have forgotten to assign some other variable it was passing in?

The line throwing the exception might be this one, if you're curious. Although the line number doesn't match the one in @jayzhou3's answer...

@mwanchap
Copy link

Maybe if a guard clause was added to check for this and return a less cryptic error if the key is null?

@shide1989
Copy link

To me they should simply implement the latest version of CryptoJS

@saqibRafique
Copy link

i have the same error

good reply

@Jeh212
Copy link

Jeh212 commented Jul 16, 2021

Does anyone have the solution already for this issue? Using the method PBKDF2 is getting the same problem returning as undefined!

@aldrichdev
Copy link

I had this same problem and it was because I forgot to select the Postman environment from the dropdown in the top right corner of the app. 🤦 Reference

@arshadarshu028
Copy link

arshadarshu028 commented Apr 22, 2022

Please check is your signature is valid for CryptoJS , If in case the signature is undefined then you will get the above error.

@naveensh26
Copy link

ERROR TypeError: undefined is not an object (evaluating '_reactNativeCryptoJs.default.algo.HMAC.create')

Any help for HMAC REACT NATIVE

var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, "Secret Passphrase");
hmac.update("Message Part 1");
hmac.update("Message Part 2");
hmac.update("Message Part 3");

var hash = hmac.finalize();

console.log("messaging part ----------" + hash);

// var hash = CryptoJS.HmacSHA256("Message", "Secret Passphrase");
// console.log("hash---------- "+ hash)

ERROR TypeError: undefined is not an object (evaluating '_reactNativeCryptoJs.default.algo.HMAC.create')
All are same error any help

@EscpLA
Copy link

EscpLA commented Jul 28, 2022

I also had the same error. ERROR TypeError: Cannot read property 'sigBytes' of undefined at new init (crypto-js.js:1913) at Object.HmacSHA256 (crypto-js.js:744) Later I put alert on parameters then found that one parameter is undefined. Please check parameters.

This is exactly my problem, thans a lot

@wangxiaoer5200
Copy link

CryptoJS.HmacSHA1:
maybe one of the parameters of the hash method before obtaining the signature is null

@aravind3566
Copy link

On encryption.js

Just replace line from var hashKey = CryptoJS.PBKDF2 to var hashKey = CryptoJS.HmacSHA1

@AlexC-ux
Copy link

AlexC-ux commented Oct 11, 2023

same issue

const base64 = btoa(CryptoJS.HmacSHA1("/v1/request/callback/" + query + CryptoJS.MD5(query)), secret);

@Rotem-55
Copy link

took me a while to figure this out. HmacSHA256 is not receiving all parameters, or receives "undefined".

So how did you fix it? I'm afraid that's my problem either.

@msantiago-plana
Copy link

msantiago-plana commented Oct 2, 2024

My error was happening on the following code

CryptoJS.HmacSHA256(rawSignature, secret);

my rawSignature was "undefined:123456" and my secret was "undefined", fixing these undefined fixed my problem.

@chiragtatva
Copy link

in my case CryptoJS.HmacSHA256(arg1, arg2) the value of arg1 or arg2 passed in the function was undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests